文章出處

#include<stdio.h>
#include<stdlib.h>
main()
{int a,b,op,os;
 printf(" [每課一練 媽媽再也不用擔心我的學習]\n");
aq1: printf("選擇您想挑戰的運算法則\n");/*新版本跟新如下*/
 printf("0.退出 1.加法 2.減法 3.乘法 4.除法 5.做分數題\n");/*添加退出功能*//*增加分數計算*//*增加隨機數范圍0~100*/
 scanf("%d",&op);
 if(op==0)
     exit;
 switch(op)
 {
aq: case 1:
 a=rand()%100;b=rand()%100;
 printf("題目為:%d + %d = ?\n\n",a,b);
 printf("1.查看答案 2.做下一題\n");
 scanf("%d",&os);
 if(os==1)
 {printf("%d + %d =%d\n\n\n",a,b,a+b);
 goto aq1;
 }
 else
 goto aq;
 break;
at: case 2:a=rand()%100;b=rand()%100;
 printf("題目為:%d - %d = ?\n\n",a,b);
 printf("1.查看答案 2.做下一題\n");
 scanf("%d",&os);
 if(os==1)
 {printf("%d - %d =%d\n\n\n",a,b,a-b);
 goto aq1;
 }
 else
 goto at;
 break;
aq2: case 3:
 a=rand()%100;b=rand()%100;
 printf("題目為:%d * %d = ?\n\n",a,b);
 printf("1.查看答案 2.做下一題\n");
 scanf("%d",&os);
 if(os==1)
 {printf("%d * %d =%d\n\n\n",a,b,a*b);
 goto aq1;
 }
 else
 goto aq2;
 break;
aq3: case 4:
 a=rand()%100;b=rand()%100;
 printf("題目為:%d / %d = ?\n\n",a,b);
 printf("1.查看答案 2.做下一題\n");
 scanf("%d",&os);
 if(os==1)
 {printf("%d / %d =%d\n\n\n",a,b,a/b);
 goto aq1;
 }
 else
 goto aq3;
 break;
 aq5: case 5:
 a=rand()%100;b=rand()%100;
 printf("題目為:%d / %d = ?\n\n",a,b);
 printf("1.查看答案 2.做下一題\n");
 scanf("%d",&os);
 if(os==1)
 {printf("%d / %d =%d\n\n\n",a,b,a/b);
 goto aq1;
 }
 else
 goto aq5;
 }
}
 


文章列表




Avast logo

Avast 防毒軟體已檢查此封電子郵件的病毒。
www.avast.com


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()