| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1304 人关注过本帖
标题:system("pause");为什么失灵求大神帮忙
取消只看楼主 加入收藏
EricBUPT
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2012-12-28
结帖率:0
收藏
已结贴  问题点数:20 回复次数:2 
system("pause");为什么失灵求大神帮忙
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<ctype.h>
#include<windows.h>
#include <conio.h>
#include<time.h>


int main()
{
    char ID[7];
    srand(time(NULL));
    int validation=0;
    int judge(char []);
    int select,i,yunsuan,ysy1,ysy2,result,ans,zq,cw;
   
    zq=0;
    cw=0;
    while(validation==0)
    {
                     printf("请输入您的ID号码");
                     scanf("%s",&ID);
                     validation=judge(ID);
                     if(validation==0)
                     {
                                     printf("无效的ID号码\n");
                     }
    }
    printf("输入1开始测试\n");
    printf("输入2查看历史成绩\n");
    printf("输入3退出\n");
    scanf("%d",&select);
    switch(select)
    {
                  case 1:
                       for (i=1;i<=10;i++)//进行十次运算
                       {
                           yunsuan=1+rand()%4;//随机选择运算类型
                           switch(yunsuan)
                           {
                                          case 1://加法
                                                 ysy1=100;
                                                 ysy2=100;
                                                 while(ysy1+ysy2>100)
                                                 {
                                                                     ysy1=0+rand()%101;
                                                                     ysy2=0+rand()%101;
                                                 }
                                                 result=ysy1+ysy2;
                                                 printf("%d+%d=",ysy1,ysy2);
                                                 scanf("%d",ans);
                                                 if(ans==result)
                                                 zq++;
                                                 else
                                                 cw++;
                                                 break;
                                          case 2://减法
                                                 ysy1=1;
                                                 ysy2=100;
                                                 while((ysy1<ysy2)||(ysy1-ysy2>100))
                                                 {
                                                                     ysy1=0+rand()%101;
                                                                     ysy2=0+rand()%101;
                                                 }
                                                 result=ysy1-ysy2;
                                                 printf("%d-%d=",ysy1,ysy2);
                                                 scanf("%d",ans);
                                                 if(ans==result)
                                                 zq++;
                                                 else
                                                 cw++;
                                                 break;
                                          case 3://乘法
                                                 ysy1=100;
                                                 ysy2=100;
                                                 while(ysy1*ysy2>100)
                                                 {
                                                                     ysy1=0+rand()%101;
                                                                     ysy2=0+rand()%101;
                                                 }
                                                 result=ysy1*ysy2;
                                                 printf("%d*%d=",ysy1,ysy2);
                                                 scanf("%d",ans);
                                                 if(ans==result)
                                                 zq++;
                                                 else
                                                 cw++;
                                                 break;
                                          case 4://除法
                                                 ysy1=1000;
                                                 ysy2=3;
                                                 while((ysy1/ysy2>100)||(ysy1%ysy2!=0))
                                                 {
                                                                     ysy1=1+rand()%100;
                                                                     ysy2=1+rand()%100;
                                                 }
                                                 result=ysy1/ysy2;
                                                 printf("%d/%d=",ysy1,ysy2);
                                                 scanf("%d",ans);
                                                 if(ans==result)
                                                 zq++;
                                                 else
                                                 cw++;
                                                
                           }//switch结束
                       }//循环结束
                           break;   
                  //case 2:;break;
                  //case 3:;break;
                  //default:break;
    }//switch结束
printf("hi");
system("pause");
return 0;
}//main结束


int judge(char a[7])
{
    int b;
    if((a[0]>=65)&&(a[0]<=90)&&(a[1]>=65)&&(a[1]<=90)&&(a[6]=='\0'))
    b=1;
    else
    b=0;
    return b;
}
 
搜索更多相关主题的帖子: 号码 include system result 
2012-12-28 00:16
EricBUPT
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2012-12-28
收藏
得分:0 
回复 2楼 yuccn
我用getchar();也是不管用的
2012-12-28 00:35
EricBUPT
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2012-12-28
收藏
得分:0 
回复 2楼 yuccn
源代码在这里,不知您是否愿意帮我调试一下
那个ID是两个大写字母加四个数字
2012-12-28 00:36
快速回复:system("pause");为什么失灵求大神帮忙
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024128 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved