| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 375 人关注过本帖
标题:第一次发帖,请指教
只看楼主 加入收藏
为你呼吸
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2007-10-29
收藏
 问题点数:0 回复次数:1 
第一次发帖,请指教

/* 为你呼吸 这个软件实现了四则运算,请大家多指教
2007.10.31 */
#include <stdio.h>
void jiafa(int*,int*);
void jianfa(int*,int*);
void chengfa(int*,int*);
void chufa(int*,int*);
#include <stdlib.h>
#include <time.h>
void main()
{
int select,a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0; //功能菜单
do
{ system("cls"); //系统清屏
printf("\n\n\t请选择功能: \n");
printf("\n\t1.练习加法运算\n\t2.练习减法运算\n\t3.练习乘法运算\n\t4.练习除法运算\n\t5.退出\n");
printf("\n\n\t请选择:");
scanf("\t%d",&select);

if(select==5)
break;
switch(select)
{
case 1: jiafa(&a,&b); break; //加法运算
case 2: jianfa(&c,&d); break; //减法运算
case 3: chengfa(&e,&f);break; //乘法运算
case 4: chufa(&g,&h); break; //除法运算
default: printf("\t输入有误,请在0~~6之间选择.\n");
}
}while(1);
system("cls");
printf("\n\n\t \t加 减 乘 除\n");
printf("\t \t==========================\n");
printf("\t总题数:\t%2d %2d %2d %2d\n",a*10,c*10,e*10,f*10);
printf("\t正确率:\t%2d%% %2d%% %2d%% %2d%%\n\n",b,d,f,h);
printf("\t您的");
if((b<60) && (a!=0))
{printf("加法");
i++;
}
if((d<60) && (c!=0))
{
if(i==1)
{
printf("和");
}
printf("减法");
i++;
}
if((f<60) && (e!=0))
{
if(i!=0)
{
printf("和");
}
printf("乘法");
}
if((h<60) && (g!=0))
{
if(i!=0)
{
printf("和");
}
printf("除法");
}
printf("正确率低于60%,需继续努力......\n\n");
}


//加法运算;
void jiafa(int *p1,int *p2)
{
int select1,i,a,b,c,d,f=0;
char e;
int d1=0;
do{
system("cls");
printf("\n\n\t 加 法 运 算\n");
printf("\t本模块共有三个难度供您选择: \n");
printf("\t1.0~~100\n\t2.0~~1000\n\t3.0~~10000\n\t4.返回主菜单\n");
printf("\n\t请选择难度:");
scanf("%d",&select1);
switch(select1)
{
case 1:
for(i=0;i<10;i++)
{
srand((unsigned)time(NULL));
a=rand()%100;
b=rand()%100;
printf("\t%2d+%2d=",a,b);
scanf("%d",&c);
if(c==a+b)
{
printf("\t正确\n");
d1++;
}
else
printf("\t错误:正确答案是%d\n",a+b);
}
break;
case 2:
for(i=0;i<10;i++)
{
a=rand()%1000;
b=rand()%1000;
printf("\t%3d+%3d=",a,b);
scanf("%d",&c);
if(c==a+b)
{ printf("\t正确\n");
d1++;}
else
printf("\t错误:正确答案是%d\n",a+b);
}
break;
case 3:
for(i=0;i<10;i++)
{
a=rand()%10000;
b=rand()%10000;
printf("\t%4d+%4d=",a,b);
scanf("%d",&c);
if(c==a+b)
{printf("\t正确\n");
d1++;}
else
printf("\t错误:正确答案是%d\n",a+b);
}
default:
printf("选择错误\n");
break;
}
printf("\n\t是否继续:(Y/N):");
fflush(stdin);
e=getchar();
f++;
}while((e=='y') || (e=='Y'));
d=d1*10/f;
printf("\n\n\t你总共做了%d到题 正确率:%d%%\n",10*f,d);
*p1=f;
*p2=d;
}


//减法运算;
void jianfa(int *p3,int *p4)
{
int select1,i,a,b,c,d,f=0;
char e;
int d1=0;
do{ system("cls");
srand((unsigned)time(NULL));
printf("\n\n\t 减 法 运 算\n");
printf("\t本模块共有三个难度供您选择: \n");
printf("\t1.0~~100\n\t2.0~~1000\n\t3.0~~10000\n\t4.返回主菜单\n");
printf("\n\t请选择难度:");
scanf("%d",&select1);

switch(select1)
{
case 1:
for(i=0;i<10;i++)
{
a=rand()%100;
b=rand()%100;
printf("\t%2d-%2d=",a,b);
scanf("%d",&c);
if(c==a-b)
{printf("\t正确\n");
d1++;}
else
printf("\t错误:正确答案是%d\n",a-b);
}
break;
case 2:
for(i=0;i<10;i++)
{
a=rand()%1000;
b=rand()%1000;
printf("\t%3d-%3d=",a,b);
scanf("%d",&c);
if(c==a-b)
{ printf("\t正确\n");
d1++;}
else
printf("\t错误:正确答案是%d\n",a-b);
}
break;
case 3:
for(i=0;i<10;i++)
{
a=rand()%10000;
b=rand()%10000;
printf("\t%4d-%4d=",a,b);
scanf("%d",&c);
if(c==a-b)
{printf("\t正确\n");
d1++;}
else
printf("\t错误:正确答案是%d\n",a-b);
}
default:
printf("选择错误\n");
break;
}
printf("\n\t是否继续:(Y/N):");
fflush(stdin);
e=getchar();
f++;
}while((e=='y') || (e=='Y'));
d=d1*10/f;
printf("\n\n\t你总共做了%d到题 正确率:%d%%\n",10*f,d);
*p3=f;
*p4=d;
}


//乘法运算;
void chengfa(int *p5,int *p6)
{
int select1,i,a,b,c,d,f=0;
char e;
int d1=0;
do{ system("cls");
srand((unsigned)time(NULL));
printf("\n\n\t 乘 法 运 算\n");
printf("\n\n\t本模块共有三个难度供您选择: \n");
printf("\t1.0~~100\n\t2.0~~1000\n\t3.0~~10000\n\t4.返回主菜单\n");
printf("\n\t请选择难度:");
scanf("%d",&select1);
switch(select1)
{
case 1:
for(i=0;i<10;i++)
{
a=rand()%100;
b=rand()%100;
printf("\t%2d*%2d=",a,b);
scanf("%d",&c);
if(c==a*b)
{printf("\t正确\n");
d1++;}
else
printf("\t错误:正确答案是%d\n",a*b);
}
break;
case 2:
for(i=0;i<10;i++)
{
a=rand()%1000;
b=rand()%1000;
printf("\t%3d*%3d=",a,b);
scanf("%d",&c);
if(c==a*b)
{ printf("\t正确\n");
d1++;}
else
printf("\t错误:正确答案是%d\n",a*b);
}
break;
case 3:
for(i=0;i<10;i++)
{
a=rand()%10000;
b=rand()%10000;
printf("\t%4d*%4d=",a,b);
scanf("%d",&c);
if(c==a*b)
{printf("\t正确\n");
d1++;}
else
printf("\t错误:正确答案是%d\n",a*b);
}
default:
printf("选择错误\n");
break;
}
printf("\n\t是否继续:(Y/N):");
fflush(stdin);
e=getchar();
f++;
}while((e=='y') || (e=='Y'));
d=d1*10/f;
printf("\n\n\t你总共做了%d到题 正确率:%d%%\n",10*f,d);
*p5=f;
*p6=d;
}


//除法运算;
void chufa(int *p7,int *p8)
{ system("cls");
int select1,i,a,b,d,f=0;
float c;
char e;
int d1=0;
do{
srand((unsigned)time(NULL));
printf("\n\n\t 除 法 运 算\n");
printf("\t本模块共有三个难度供您选择:: \n");
printf("\t1.0~~100\n\t2.0~~1000\n\t3.0~~10000\n\t4.返回主菜单\n");
printf("\n\t请选择难度:");
scanf("%d",&select1);
switch(select1)
{
case 1:
for(i=0;i<10;i++)
{
a=rand()%100;
b=rand()%100;
printf("\t%2d/%2d=",a,b);
scanf("%f",&c);
if(c==float(a)/b)
{printf("\t正确\n");
d1++;}
else
printf("\t错误:正确答案是%7.2f\n",float(a)/b);
}
break;
case 2:
for(i=0;i<10;i++)
{
a=rand()%1000;
b=rand()%1000;
printf("\t%3d/%3d=",a,b);
scanf("%f",&c);
if(c==float(a)/b)
{ printf("\t正确\n");
d1++;}
else
printf("\t错误:正确答案是%7.2f\n",float(a)/b);
}
break;
case 3:
for(i=0;i<10;i++)
{
a=rand()%10000;
b=rand()%10000;
printf("\t%4d/%4d=",a,b);
scanf("%f",&c);
if(c==float(a)/b)
{printf("\t正确\n");
d1++;}
else
printf("\t错误:正确答案是%7.2f\n",float(a)/b);
}
default:
printf("选择错误\n");
break;
}
printf("\n\t是否继续:(Y/N):");
fflush(stdin);
e=getchar();
f++;
}while((e=='y') || (e=='Y'));
d=d1*10/f;
printf("\n\n\t你总共做了%d到题 正确率:%d%%\n",10*f,d);
*p7=f;
*p8=d;
}

搜索更多相关主题的帖子: int void 发帖 include 
2007-10-31 22:04
a19870502
Rank: 1
等 级:新手上路
帖 子:114
专家分:0
注 册:2007-10-31
收藏
得分:0 

好长~~~不过我只学过C++

2007-11-01 00:11
快速回复:第一次发帖,请指教
数据加载中...
 
   



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

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