中易网

中国有句俗语叫“三天打鱼两天晒网”。某人从1990年1月1日起开始“三天

答案:1  悬赏:50  
解决时间 2021-01-12 02:51
  • 提问者网友:杀生予夺
  • 2021-01-11 08:03
中国有句俗语叫“三天打鱼两天晒网”。某人从1990年1月1日起开始“三天
最佳答案
  • 二级知识专家网友:酒醒三更
  • 2021-01-11 08:13
#include
#include #include
void main(){int i, j; int num = 0, count = 0; printf("练习开始,按回车结束\n");printf("请输入要生成的字母个数:\n");scanf("%d", num);
srand((unsigned)time(NULL));char *p=(char *)malloc((num+1) * sizeof(char));if(p != NULL){for(i = 0; i < num; i++){p[i] = rand()%26 + 'a';printf("%c", p[i]); }printf("\n");}
clock_t start, end; char *q=(char *)malloc(num * sizeof(char));
if(q != NULL){start = clock();scanf("%s", q);end = clock();}for(j = 0; j < num; j++){if(p[j] == q[j])count++;}
float rate;rate = (float)count / (float)num; printf("输入正确了%d个字母,正确率为%d%%.\n", count, (int)(rate*100));printf("共用了%ld秒.\n", (end-start)/1000);free(p);free(q);
system("pause"); }
请放心使用
有问题的话请追问
满意请,
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息!
大家都在看
推荐信息