好久不来机吧发帖了,也不去管事。。今日看吧务群里又有人无头苍蝇般到处找Roll点工具,索性自己写了个。。。
代码应该没啥问题,最后保存退出的时候我让它生成了个record.txt的文件,方便事后查看。
btw,过场动画……当作小小的玩笑好了
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<windows.h>
void load()
{
printf("\t\t\t\t\t\t\t Copyright by Roy\n\n\n\t\t\t\t Loading\n");
for(int i=0;i<80;i++)
{
printf("|");
Sleep(20);
}
printf("\n\n");
system("pause");
system("cls");
}
int main()
{
int N;
int *result;
int select,i;
FILE *txt;
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
load();
printf ( "\007The current date/time is: %s\n", asctime (timeinfo) );
printf("Enter the total number: ");
scanf("%d",&N);
result=(int*)malloc(N*sizeof(int));
srand(time(0));
for(i=0;i<N;i++)
{
printf("Select 1 continue\t2 save & exit\t");
scanf("%d",&select);
switch(select)
{
case 1:printf("%d\n",result[i]=rand()%N+1);
result[i+1]=-1;
break;
case 2:txt=fopen("record.txt","w+");
fprintf(txt,"%s",asctime (timeinfo));
for(i=0;result[i]!=-1 && i<N;i++)
fprintf(txt,"%d ",result[i]);
fclose(txt);
return 0;
}
}
}
代码应该没啥问题,最后保存退出的时候我让它生成了个record.txt的文件,方便事后查看。
btw,过场动画……当作小小的玩笑好了
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<windows.h>
void load()
{
printf("\t\t\t\t\t\t\t Copyright by Roy\n\n\n\t\t\t\t Loading\n");
for(int i=0;i<80;i++)
{
printf("|");
Sleep(20);
}
printf("\n\n");
system("pause");
system("cls");
}
int main()
{
int N;
int *result;
int select,i;
FILE *txt;
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
load();
printf ( "\007The current date/time is: %s\n", asctime (timeinfo) );
printf("Enter the total number: ");
scanf("%d",&N);
result=(int*)malloc(N*sizeof(int));
srand(time(0));
for(i=0;i<N;i++)
{
printf("Select 1 continue\t2 save & exit\t");
scanf("%d",&select);
switch(select)
{
case 1:printf("%d\n",result[i]=rand()%N+1);
result[i+1]=-1;
break;
case 2:txt=fopen("record.txt","w+");
fprintf(txt,"%s",asctime (timeinfo));
for(i=0;result[i]!=-1 && i<N;i++)
fprintf(txt,"%d ",result[i]);
fclose(txt);
return 0;
}
}
}
Roll_MKPB.exe
大小:80.00KB下载:32次转存:3次