| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 620 人关注过本帖
标题:为啥不能调用下面的函数
只看楼主 加入收藏
qiufengshang
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2013-4-15
结帖率:0
收藏
 问题点数:0 回复次数:3 
为啥不能调用下面的函数
#include <stdio.h>
#include<stdlib.h>
#include<time.h>
int main(void)
{
    int a,b,c,q;
srand((int)time(0));
int cha(int x,int y);
a=rand()%100;
b=rand()%100;
c=subtract(a,b);
printf("%d-%d=\n",a,b,subtract(a,b));
scanf("%d",&q);
if (c==q)
printf("\n表扬\n");
else printf("%d",c);
system("Pause");
return 0;
}
int subtract(int a,int b)
{
   int temp,n;
    if(a>b)
    n=a-b;
   else if(a<=b)
   {
   temp=a;
    a=b;
    b=temp;
     n=a-b;
}
    return n;
    }
搜索更多相关主题的帖子: void cha include system return 
2013-04-15 18:23
hahayezhe
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:湖南张家界
等 级:贵宾
威 望:24
帖 子:1386
专家分:6999
注 册:2010-3-8
收藏
得分:0 
int subtract(int a,int b) main前没有声明  你编译能过?
2013-04-16 08:51
qiufengshang
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2013-4-15
收藏
得分:0 
#include <stdio.h>
#include<stdlib.h>
#include<time.h>
int subtract(int x,int y)
{
   int temp,n;
    if(x>y)
    n=x-y;
   else if(x<=y)
   {
   temp=x;
    x=y;
    y=temp;
     n=x-y;
}
    return n;
    }
int main(void)
{
    int a,b,c,q,z;
srand((int)time(NULL));
int cha(int x,int y);
for(z=1;z<=3;z++)
{
do
{
a=rand()%100+1;
b=rand()%100+1;
c=subtract(a,b);
}
while(a<b);
printf("%d-%d=\n",a,b);
scanf("%d",&q);
if (c==q)
printf("\n表扬\n");
else printf("%d",c);
system("Pause");
}
return 0;
}


如果这样能调用?
2013-04-16 22:57
czzdcn123
Rank: 7Rank: 7Rank: 7
来 自:江西
等 级:黑侠
威 望:3
帖 子:258
专家分:510
注 册:2013-3-7
收藏
得分:0 
2013-04-16 23:01
快速回复:为啥不能调用下面的函数
数据加载中...
 
   



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

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