| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1304 人关注过本帖
标题:system("pause");为什么失灵求大神帮忙
只看楼主 加入收藏
EricBUPT
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2012-12-28
结帖率:0
收藏
已结贴  问题点数:20 回复次数:8 
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
yuccn
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:何方
等 级:版主
威 望:167
帖 子:6815
专家分:42393
注 册:2010-12-16
收藏
得分:10 
怎么个失灵?

可以用getchar();来代替的

我行我乐
公众号:逻辑客栈
我的博客:
https://blog.yuccn. net
2012-12-28 00:29
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
StarFall
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:1
帖 子:193
专家分:553
注 册:2012-10-1
收藏
得分:10 
PAUSE要大写吧。- -

去追寻更高的技术领域。永不停止。
2012-12-28 08:14
StarFall
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:1
帖 子:193
专家分:553
注 册:2012-10-1
收藏
得分:0 
加fflush(stdin);getch();也可以

去追寻更高的技术领域。永不停止。
2012-12-28 08:17
yuccn
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:何方
等 级:版主
威 望:167
帖 子:6815
专家分:42393
注 册:2010-12-16
收藏
得分:0 
回复 5楼 StarFall
cmd命令,不分大小写的

我行我乐
公众号:逻辑客栈
我的博客:
https://blog.yuccn. net
2012-12-28 09:59
conan8732
Rank: 2
等 级:论坛游民
帖 子:24
专家分:43
注 册:2012-8-8
收藏
得分:0 
后面的while循环不懂  感觉可以不要   直接取随机数就行
2013-01-10 17:29
allmy34
Rank: 2
等 级:论坛游民
帖 子:14
专家分:19
注 册:2012-12-29
收藏
得分:0 
case 4 后面没break
2013-01-17 23:08
快速回复:system("pause");为什么失灵求大神帮忙
数据加载中...
 
   



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

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