zoukankan      html  css  js  c++  java
  • 第一次作业

    看着隔壁床位的宿友刀疤哥花了一中午没打码还偷睡觉 默默认真做作业(想想自己都怕)┑( ̄Д  ̄)┍

    还是花了很长时间才做的简单的程序代码 就这样了( ̄△ ̄;)

    源程序:

    #include<stdio.h>

    #include<stdlib.h>

    void meau();

    void score(int);

    int test(int);

    int gchoice();

    void meau()

    {  

    printf("欢迎使用熊孩子四则运算练习程序\n");  

    printf("选择要进行的练习(每个练习题数为5):\n");  

    printf("\t1、加法练习\n\t2、减法练习\n\t3、乘法练习\n\t4、除法练习\n\t0、退出程序\n");  

    printf("请选择:");

    }

    void score(int n)

    {  

    int score=0;  

    int i=0;

    for(i=1;i<=5;i++)  

    {   

    score=score+test(n);  

    }  

    printf("哎呀呀0.0 !你做对了%d道题!\n\n",score); }

    int test(int n)

    {  

    int Ranswer=0;  

    int Uanswer=0;  

    int t=0;  

    char k;  

    int a=0;  

    int b=0;  

    a=rand()%10;  

    b=rand()%10;

    switch(n)  

    {  

    case 1:   

    k='+';   

    break;  

    case 2:   

    k='-';   

    break;  

    case 3:   

    k='*';   

    break;  

    case 4:   

    k='/';   

    break;  

    }

    if((k=='-')&&(a<b))  

    {   t=a;   a=b;   b=t;  }

    if(k=='/')  

    {   if(b==0)   {    b=1;   }   a=a*b;  }

    printf("%d%c%d=",a,k,b);  

    scanf("%d",&Uanswer);

     switch(k)  

    {  

    case '+':  

    Ranswer=a+b;   

    break;  case '-':   

    Ranswer=a-b;   

    break;  

    case '*':   

    Ranswer=a*b;   

    break;  

    case '/':   

    Ranswer=a/b;   

    break;  

    }  

    if(Uanswer==Ranswer)  

    {   printf("哟呵!做对了!\n");   return 1;  }  

    else  

    {   printf("纳尼!做错了!\n");   return 0;  } }

    int gchoice()

    {  

    int choice;  

    scanf("%d",&choice);  

    return choice;

    }

    int main(void)

    {  

    int choice=0;  

    do {   

    meau();      

    choice=gchoice();   

    if(choice<0 || choice>4)   

    {    

    choice=1;   

    }    

     /*if(choice<0 || choice>4)   {    printf("输入错误!重新输入\n");    meau();   }   if(choice==0)   {    break;    }*/

    想弄成输入0~4外的数字报错 发现换成绿色代码后有新的错误 未解决

    if(choice==0)   

    {    

    break;    

    }

     score(choice);  

    }while(choice!=0);

     printf("再见熊孩子!后会有期!\n");  

    return 0;

    }

  • 相关阅读:
    web页面常用方法及INI文件的读取方法
    winform 三个Panel左右切换(panel里面填充图片)
    图片渐出轮播的效果
    Winform跑马灯——Graphics运用
    .net 3.5 新功能重写ToInt()方法
    style.display
    SQL: 分页SQL SQL2005函数分页!
    JS: 验证输入必须为数字
    Table 里面点标题会进行排序
    在Div中绑定数据
  • 原文地址:https://www.cnblogs.com/chensiming/p/4369689.html
Copyright © 2011-2022 走看看