| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 342 人关注过本帖
标题:这个程序哪错了
只看楼主 加入收藏
enchk
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2006-9-23
收藏
 问题点数:0 回复次数:2 
这个程序哪错了

这个程序哪错了,为什么没有输出啊

#include<stdio.h>
#include<stdlib.h>
#include<time.h>

int question(void);
float answer(int result,int rand1,int rand2);
void rAnswer(void);
void wAnswer(void);
void rateFunction(float);

static int rand1,rand2;
static int wcount=0,rcount=0;

int main()
{
srand((int)time(0));
do{
int question(void);
float answer(int result,int rand1,int rand2);
void rateFunction(float rate);
}while(rcount+wcount==15);
return 0;
}

int question()
{
int result;
rand1=1+(int)(rand()%10);
rand2=1+(int)(rand()%10);
printf("How much is %d times %d",rand1,rand2);
scanf("%d",&result);
printf("%d",result);
return (result);
}

float answer(int result,int rand1,int rand2)
{
float rate;
if (result==rand1*rand2)
{void rAnswer();
rcount++;
}
else
{void wAnswer();
wcount++;
}
rate=rcount/(rcount+wcount);
return rate;
}

void rAnswer(void)
{ int rRand;
rRand=1+rand()%4;
switch(rRand)
{
case 1:printf("Very good!\n");break;
case 2:printf("Excellent!\n");break;
case 3:printf("Nice work!\n");break;
case 4:printf("Keep up the good work!\n");break;
}
}

void wAnswer(void)
{ int wRand;
wRand=1+rand()%4;
switch(wRand)
{
case 1:printf("No.pelase try again.\n");break;
case 2:printf("Wrong.Try once more.\n");break;
case 3:printf("Don't giue up!\n");break;
case 4:printf("No,keep trying.\n");break;
}
}

void rateFunction(float rate)
{ if (rate<=0.75)
{
printf("Please ask your instruyctor for extra help");
exit(0);
}
}



[此贴子已经被作者于2007-4-12 18:00:32编辑过]

2007-04-12 17:59
Javal
Rank: 1
等 级:新手上路
威 望:1
帖 子:108
专家分:0
注 册:2006-5-7
收藏
得分:0 

#include<stdio.h>
#include<stdlib.h>
#include<time.h>

int question(void);
float answer(int result,int rand1,int rand2);
void rAnswer(void);
void wAnswer(void);
void rateFunction(float);

static int rand1,rand2,result;
static int wcount=0,rcount=0;
static float rate;

int main()
{
srand((int)time(0));
do{
question();
answer(result,rand1,rand2);
rateFunction(rate);
}while(rcount+wcount==15);
return 0;
}

int question()
{
//int result;
rand1=1+(int)(rand()%10);
rand2=1+(int)(rand()%10);
printf("How much is %d times %d",rand1,rand2);
scanf("%d",&result);
printf("%d",result);
return (result);
}

float answer(int result,int rand1,int rand2)
{
//float rate;
if (result==rand1*rand2)
{void rAnswer();
rcount++;
}
else
{void wAnswer();
wcount++;
}
rate=rcount/(rcount+wcount);
return rate;
}

void rAnswer(void)
{ int rRand;
rRand=1+rand()%4;
switch(rRand)
{
case 1:printf("Very good!\n");break;
case 2:printf("Excellent!\n");break;
case 3:printf("Nice work!\n");break;
case 4:printf("Keep up the good work!\n");break;
}
}

void wAnswer(void)
{ int wRand;
wRand=1+rand()%4;
switch(wRand)
{
case 1:printf("No.pelase try again.\n");break;
case 2:printf("Wrong.Try once more.\n");break;
case 3:printf("Don't giue up!\n");break;
case 4:printf("No,keep trying.\n");break;
}
}

void rateFunction(float rate)
{ if (rate<=0.75)
{
printf("Please ask your instruyctor for extra help");
exit(0);
}
}

注意變量的聲明

[此贴子已经被作者于2007-4-12 18:09:32编辑过]


猝然临之而不惊,无故加之而不怒 /?spaced" target="_blank">Linux C资料
2007-04-12 18:08
enchk
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2006-9-23
收藏
得分:0 
回复:(Javal)#include#include

楼上回答的不对啊
虽有问题输出,但question();以后的程序没有运行

2007-04-14 12:01
快速回复:这个程序哪错了
数据加载中...
 
   



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

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