一位数加法程序
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<Windows.h>
using namespace std;
int l,r,s[5],rr;
double mintime=100,a[1005];
int main()
{
while (1)
{
for (int i=1;i<=30;++i) putchar('*');
puts("");
printf("*Now: *\n*Accepted : %3d *\n*Time limit exceeded : %3d *\n*Wrong answer : %3d *\n",s[1],s[2],s[3]);
printf("*max time : ");
if (mintime==100) printf("%.2lf",0);
else printf("%.2lf",mintime);
printf(" *\n");
for (int i=1;i<=30;++i) putchar('*');
puts("");
printf("*目前题目情况: *\n");
if (rr<=10)
{
for (int i=1;i<=10-rr;++i) printf("* *\n");
for (int i=1;i<=rr;++i)
{
printf("*%3d : ",i);
if (!a[i]) printf("/");
else printf("%.2lf",a[i]);
printf(" *\n");
}
}
else
for (int i=rr-9;i<=rr;++i)
{
printf("*%3d : ",i);
if (!a[i]) printf("/");
else printf("%.2lf",a[i]);
printf(" *\n");
}
for (int i=1;i<=30;++i) putchar('*');
puts("");
int x=rand()%9+1,y=rand()%9+1,c=0;
char cc[105];
printf("PLUS : %d + %d = ",x,y);
scanf("%s",cc);
int len=strlen(cc);
for (int i=0;i<len;++i) c=10*c+cc[i]-'0';
l=r;
r=clock();
if (x+y==c)
{
if (r-l<=1000) printf("Accepted, time used: %.2lfs\n",(r-l)/1000.0),s[1]++,a[++rr]=(r-l)/1000.0,mintime=min(mintime,(r-l)/1000.0);
else printf("Time limit exceeded ,time used: %.2lfs\n",(r-l)/1000.0),s[2]++,a[++rr]=(r-l)/1000.0,mintime=min(mintime,(r-l)/1000.0);
}
else printf("Wrong answer!\n"),s[3]++,a[++rr]=0;
Sleep(200);
system("cls");
}
return 0;
}
特垃圾代码。。