From f19bdcc45421bc7d7fa4b3c411f8d8590e861fa3 Mon Sep 17 00:00:00 2001 From: p10369542 <710993622@qq.com> Date: Fri, 11 Jan 2019 15:01:01 +0800 Subject: [PATCH] first commit --- 1.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 1.c diff --git a/1.c b/1.c new file mode 100644 index 0000000..dc45aaf --- /dev/null +++ b/1.c @@ -0,0 +1,104 @@ +#include +#include //随机数 +int main() //主函数 +{int a,b,c,i=0,j=0,num=0,k; //j代表分数, + rule(); + while(1) + { a=rand()%50; + b=rand()%50; + c=rand(); + if(a0&&(a+b)<50) + { num++; + printf("NO.%d ",num); + j=j+exam(a,b,c); + i++; + } + if(i>=10) + { great(j); + break; + } + } + printf("==================\n"); +return 0; +} +int rule() //定义规则 +{ printf("===============================\n"); + printf("欢迎小朋友来答题,规则如下:\n"); + printf("共有10道题,每题有三次答题机会。\n"); + printf("第一次答对得10分\n"); + printf("第二次答对得7分\n"); + printf("第三次答对得5分,答错不得分.\n"); + printf("下面请开始你的表演!!!\n"); + printf("================================\n"); + return 0; +} +int great(int n) //定义成绩等级 +{ printf("你的成绩是%d分\n",n); + if(n>90) + printf("SMATE\n"); + else if(n>=80&&n<=90) + printf("GOOD\n"); + else if(n>=70&&n<80) + printf("OK\n"); + else if(n>=60&&n<70) + printf("PASS\n"); + else + printf("TRY AGAIN\n"); + return 0; +} +int exam(int a,int b,int c) //计算得分 +{ int m,n,j=0,i; + if(c%2==0) + { n=a-b; + printf("%d-%d=",a,b); + for(i=0;i<3;i++) + { scanf("%d",&m); + if(n==m) + { if(i==0) + j=10; + else if(i==1) + j=7; + else + j=5; + break; + } + else + { printf(" 答案错误\n"); + if(i<2) + printf(" 请重新输入:"); + if(i==2) + printf(" 正确答案是%d\n",n); + } + } + } + else if(c%2!=0) + { n=a+b; + printf("%d+%d=",a,b); + for(i=0;i<3;i++) + { scanf("%d",&m); + if(m==n) + { if(i==0) + j=10; + else if(i==1) + j=7; + else + j=5; + break; + } + else + { printf(" 答案错误\n"); + if(i<2) + printf(" 请重新输入:"); + if(i==2) + printf(" 正确答案是%d\n",n); + } + } + } + printf("__________________\n"); + return j; +}