| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 665 人关注过本帖
标题:请专家改下程序(使之符合要求)
只看楼主 加入收藏
lubhsb
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2010-6-30
收藏
 问题点数:0 回复次数:4 
请专家改下程序(使之符合要求)
C语言程序设计--心算抢答系统
#include<stdio.h>
 #include<stdlib.h>
 #include<time.h>
 void main()
 {int simple();
  int mix();
  void exchange(int *p1,int *p2,int *p3);
  struct team
 {char name;
  int score;
 }tea[3]={{'A',100},{'B',100},{'C',100}};
  int i,p,j,t,k,n,m;
  int a,b,c;
  int result1,answer1,result2,answer2;
  int *q1,*q2,*q3;
  char ch1,ch2;
  printf("         ************************************\n");
  printf("         $                                  $\n");
  printf("         $                                  $\n");
  printf("         $ welcome jion in this competition!$\n");
  printf("         $                                  $\n");
  printf("         $                                  $\n");
  printf("         ************************************\n");
  for(i=0;i<10;i++)
  printf("\n");
  printf("input simple count number n:");
  scanf("%d",&n);
  printf("\ninput mix count number m:");
  scanf("%d",&m);
  printf("\n");
  printf(" press any key to begain ! \n");
  getch();
  printf("Begain!\n");
  printf("The first turn.\n");
  printf("This is simple count.\n");
  printf("Please look at the question:\n");
  for(p=0;p<n;p++)
 {result1=simple();
  printf("Please input one team name:");
  getchar();
  scanf("%c",&ch1);
  printf("\ninput your answer:");
  scanf("%d",&answer1);
  for(k=0;k<3;k++)
 {t=k;
  if(ch1==tea[k].name)
    if(result1==answer1)
       tea[t].score+=5;
  else
       { printf("This answer is wrong.\n");
  printf("The right answer is %d\n",result1);
  tea[t].score-=5;
       }
 }
  for(i=0;i<3;i++)
  printf("%c%d\n",tea[i].name,tea[i].score);
 }
  printf("This turn is end.\n");
  printf("\n\n\n\n\n");
  printf("The second turn begain!\n");
  printf("This is mix count!\n");
  printf("Please look at the question:\n");
  for(j=0;j<m;j++)
 {result2=mix();
  printf("please input one team:");
  getchar();
  scanf("%c",&ch2);
  printf("\ninput your answer:");
  scanf("%d",&answer2);
  for(i=0;i<3;i++)
 {t=i;
  if(ch2==tea[i].name)
    if(result2==answer2)
      tea[t].score+=10;
  else
  { printf("\nyour answer is wrong.\n");
    printf("The right answer is %d\n",result2);
   tea[t].score-=10;
  }
 }
  for(i=0;i<3;i++)
  printf("%c%d\n",tea[i].name,tea[i].score);
 }
  a=tea[0].score;b=tea[1].score;c=tea[2].score;
  if(a>b&&b>c)
  printf("%c %c %c\n",'A','B','C');
  if(a>b&&c>a)
  printf("%c %c %c",'C','A','B');
  if(a>b&&a>c&&c>b)
  printf("%c %c %c\n",'A','C','B');
  if(c>a&&c>b&&b>a)
  printf("%c %c %c\n",'C','B','A');
  if(b>a&&c>a&&b>c)
  printf("%c %c %c\n",'B','C','A');
  if(b>a&&a>c)
  printf("%c %c %c\n",'B','A','C');
  q1=&tea[0].score;
  q2=&tea[1].score;
  q3=&tea[2].score;
  exchange(q1,q2,q3);
  printf("%d %d %d\n",tea[0].score,tea[1].score,tea[2].score);
 }
  simple()
 {int s,num1,num2,stpy;
  srand((unsigned)time(NULL));
  num1=rand()%100+1;
  num2=rand()%100+1;
  stpy=rand()%4+1;
  switch(stpy)
 {case 1:s=num1+num2;
  printf("%d+%d=?\n",num1,num2);break;
  case 2:if(num1>=num2)
 {  s=num1-num2;
    printf("%d-%d=?\n",num1,num2);break;
 }
  else
 {  s=num2-num1;
    printf("%d-%d=?\n",num2,num1);break;
 }
  case 3:s=num1*num2;
  printf("%d*%d=?\n",num1,num2);break;
  case 4:s=num1/num2;
  printf("%d/%d=?\n",num1,num2);break;
 }
  return(s);
 }
  mix()
 {int t,num1,num2,num3,stpy;
  srand((unsigned)time(NULL));
  num1=rand()%9+1;
  num2=rand()%9+1;
  num3=rand()%9+1;
  stpy=rand()%4+1;
  switch(stpy)
 {case 1:t=(num1+num2)*(num2-num3);
  printf("(%d+%d)*(%d-%d)=?\n",num1,num2,num2,num3);
        break;
  case 2:t=num1*num2/num3;
  printf("%d*%d/%d=?\n",num1,num2,num3);
        break;
  case 3:t=num1*num2-num1/num3;
  printf("%d*%d-%d/%d=?\n",num1,num2,num1,num3);
        break;
  case 4:t=(num1+num2-num3)*num3/num1;
  printf("(%d+%d-%d)*%d/%d=?\n",num1,num2,num3,num3,num1);
        break;
 }
  return(t);
 }
  void exchange(int *p1,int *p2,int *p3)
 {void swap(int *x,int *y);
  if(*p1<*p2) swap(p1,p2);
  if(*p1<*p3) swap(p1,p3);
  if(*p2<*p3) swap(p2,p3);
 }
  void swap(int *x,int *y)
 {int t;
  t=*x;
  *x=*y;
  *y=t;
 }

一、问题描述:
适用于小学生数学心算抢答赛。比赛题型分为两种:“四则简单运算”和“四则混合运算”,计算机随机出题,选手抢答。要求进入每种题型比赛时,计算机均有提示,每队的记分窗口随得分情况而更新。

二、功能描述:
1、显示如下画面:



2、举办单位确定参赛的队数,每队分配一个记分窗口,底分均为100分。
3、    比赛题型分为两种:“四则简单运算”(N道题)和“四则混合运算”(M道题),N、M由举办单位确定,计算机随机出题,先出“四则简单运算”题,每出一道 ,选手抢答,做对一题加5分,做错一题减5分。后出“四则混合运算”,做对一题加10分,做错一题减10分。要求进入每种题型比赛时,计算机均有提示,每队的记分窗口随得分情况而更新。
4、    根据最后总分,由高到低宣布比赛名次,按任意键退出比赛系统。

5、    要求整个设计以人为本,用户界面友好。

三、算法提示:
1、    用简单的程序设计方法
2、    一定的窗口设计技巧
3、    简单的数据类型

四、测试数据:
随机函数产生
搜索更多相关主题的帖子: 专家 
2010-06-30 17:15
南国利剑
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:29
帖 子:1165
专家分:3536
注 册:2010-4-12
收藏
得分:0 
有什么问题?
说清楚。

南国利剑
2010-06-30 19:01
lubhsb
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2010-6-30
收藏
得分:0 
回复 2楼 南国利剑
答案不对,无论怎么回答。都是得满分。
2010-06-30 23:14
lubhsb
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2010-6-30
收藏
得分:0 
回复 2楼 南国利剑
若是能给个源程序,那感激不尽!
2010-06-30 23:15
marenshi
Rank: 2
等 级:论坛游民
帖 子:23
专家分:17
注 册:2009-10-31
收藏
得分:0 
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
void main()
{int simple();
  int mix();
  void exchange(int *p1,int *p2,int *p3);
  struct team
{char name;
  int score;
}tea[3]={{'A',100},{'B',100},{'C',100}};
  int i,p,j,t,k,n,m;
  int a,b,c;
  int result1,answer1,result2,answer2;
  int *q1,*q2,*q3;
  char ch1,ch2;
  printf("         ************************************\n");
  printf("         $                                  $\n");
  printf("         $                                  $\n");
  printf("         $ welcome jion in this competition!$\n");
  printf("         $                                  $\n");
  printf("         $                                  $\n");
  printf("         ************************************\n");
  for(i=0;i<10;i++)
  printf("\n");
  printf("input simple count number n:");
  scanf("%d",&n);
  printf("\ninput mix count number m:");
  scanf("%d",&m);
  printf("\n");
  printf(" press any key to begain ! \n");
  getch();
  printf("Begain!\n");
  printf("The first turn.\n");
  printf("This is simple count.\n");
  printf("Please look at the question:\n");
  for(p=0;p<n;p++)
{result1=simple();
  printf("Please input one team name:");
  getchar();//去掉这个
  scanf("%c",&ch1);
  printf("\ninput your answer:");
  scanf("%d",&answer1);
  for(k=0;k<3;k++)
{t=k;
  if(ch1==tea[k].name)
    if(result1==answer1)
       tea[t].score+=5;
  else
       { printf("This answer is wrong.\n");
  printf("The right answer is %d\n",result1);
  tea[t].score-=5;
       }
}
  for(i=0;i<3;i++)
  printf("%c%d\n",tea[i].name,tea[i].score);
}
  printf("This turn is end.\n");
  printf("\n\n\n\n\n");
  printf("The second turn begain!\n");
  printf("This is mix count!\n");
  printf("Please look at the question:\n");
  for(j=0;j<m;j++)
{result2=mix();
  printf("please input one team:");
  getchar();
  scanf("%c",&ch2);
  printf("\ninput your answer:");
  scanf("%d",&answer2);
  for(i=0;i<3;i++)
{t=i;
  if(ch2==tea[i].name)
    if(result2==answer2)
      tea[t].score+=10;
  else
  { printf("\nyour answer is wrong.\n");
    printf("The right answer is %d\n",result2);
   tea[t].score-=10;
  }
}
  for(i=0;i<3;i++)
  printf("%c%d\n",tea[i].name,tea[i].score);
}
  a=tea[0].score;b=tea[1].score;c=tea[2].score;
  if(a>b&&b>c)
  printf("%c %c %c\n",'A','B','C');
  if(a>b&&c>a)
  printf("%c %c %c",'C','A','B');
  if(a>b&&a>c&&c>b)
  printf("%c %c %c\n",'A','C','B');
  if(c>a&&c>b&&b>a)
  printf("%c %c %c\n",'C','B','A');
  if(b>a&&c>a&&b>c)
  printf("%c %c %c\n",'B','C','A');
  if(b>a&&a>c)
  printf("%c %c %c\n",'B','A','C');
  q1=&tea[0].score;
  q2=&tea[1].score;
  q3=&tea[2].score;
  exchange(q1,q2,q3);
  printf("%d %d %d\n",tea[0].score,tea[1].score,tea[2].score);
}
  simple()
{int s,num1,num2,stpy;
  srand((unsigned)time(NULL));
  num1=rand()%100+1;
  num2=rand()%100+1;
  stpy=rand()%4+1;
  switch(stpy)
{case 1:s=num1+num2;
  printf("%d+%d=?\n",num1,num2);break;
  case 2:if(num1>=num2)
{  s=num1-num2;
    printf("%d-%d=?\n",num1,num2);break;
}
  else
{  s=num2-num1;
    printf("%d-%d=?\n",num2,num1);break;
}
  case 3:s=num1*num2;
  printf("%d*%d=?\n",num1,num2);break;
  case 4:s=num1/num2;
  printf("%d/%d=?\n",num1,num2);break;
}
  return(s);
}
  mix()
{int t,num1,num2,num3,stpy;
  srand((unsigned)time(NULL));
  num1=rand()%9+1;
  num2=rand()%9+1;
  num3=rand()%9+1;
  stpy=rand()%4+1;
  switch(stpy)
{case 1:t=(num1+num2)*(num2-num3);
  printf("(%d+%d)*(%d-%d)=?\n",num1,num2,num2,num3);
        break;
  case 2:t=num1*num2/num3;
  printf("%d*%d/%d=?\n",num1,num2,num3);
        break;
  case 3:t=num1*num2-num1/num3;
  printf("%d*%d-%d/%d=?\n",num1,num2,num1,num3);
        break;
  case 4:t=(num1+num2-num3)*num3/num1;
  printf("(%d+%d-%d)*%d/%d=?\n",num1,num2,num3,num3,num1);
        break;
}
  return(t);
}
  void exchange(int *p1,int *p2,int *p3)
{void swap(int *x,int *y);
  if(*p1<*p2) swap(p1,p2);
  if(*p1<*p3) swap(p1,p3);
  if(*p2<*p3) swap(p2,p3);
}
  void swap(int *x,int *y)
{int t;
  t=*x;
  *x=*y;
  *y=t;
}

2010-06-30 23:16
快速回复:请专家改下程序(使之符合要求)
数据加载中...
 
   



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

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