鱼C论坛

 找回密码
 立即注册
查看: 7173|回复: 21

这段代码哪错了啊

[复制链接]
发表于 2012-10-24 12:48:11 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
#include <stido.h>
#include <math.h>

int max(int a,int b);
void main()
{
        int x,y,z;
        int max(int a,int b);
        printf("input two numbers:\n");
        scanf("%d%d",&x,&y);
        z=max(x,y);
        printf("maxmum=%d",z);
}

int max(int a,int b)
{
        if (a>b) return a;else ruturn b;
}
小甲鱼最新课程 -> https://ilovefishc.com
 楼主| 发表于 2012-10-24 14:35:16 | 显示全部楼层
太丢人了~~
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-10-24 14:40:24 | 显示全部楼层
#include <math.h>

int max(int a,int b);    这两句没用啊...
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-10-24 14:42:16 | 显示全部楼层
if (a>b) return a;else“ ruturn b”; 最后这个ruturn,也是写错了return
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-10-24 19:14:01 | 显示全部楼层
# include <stdio.h>   //stdio.h 你写成了 stido.h
# include <math.h>

int max(int a, int b);

int main(void)
{
        int x, y, z;
        int max(int a, int b);

        printf("input two numbers:\n");
        scanf("%d %d",&x, &y);
        z = max(x, y);

        printf("maxnum = %d\n",z);

        return 0;
}

int max(int a, int b)
{
        if (a > b)
        return a;
        else
        return b;   //return 你写成了 ruturn
}
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-10-24 19:21:22 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-10-24 19:21:55 | 显示全部楼层
额 我只是路过
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-10-24 20:25:30 | 显示全部楼层
math多余,ruturn笔误 ,其它没错
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-10-25 07:31:32 | 显示全部楼层
*﹏LadyG☆ 发表于 2012-10-24 19:14
# include    //stdio.h 你写成了 stido.h
# include

正解   这个写的差不多了
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-10-25 12:41:20 | 显示全部楼层
int max(int a,int b);重复定义了

补充内容 (2012-10-25 12:42):
还有#include <stido.h>
应该是stdio.h
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-10-25 13:03:43 | 显示全部楼层

  1. #include <stdio.h>

  2. int max(int a,int b);
  3. void main()
  4. {
  5.         int x,y,z;
  6.         printf("input two numbers:\n");
  7.         scanf("%d%d",&x,&y);
  8.         z=max(x,y);
  9.         printf("maxmum=%d",z);
  10. }

  11. int max(int a,int b)
  12. {
  13.         if (a>b) return a;else ruturn b;
  14. }
复制代码
这样就可以了
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-10-25 13:50:39 | 显示全部楼层
楼主,你会英语么?
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-10-25 13:51:16 | 显示全部楼层
看了你的程序我那个汗啊!!!!
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-10-25 14:01:30 | 显示全部楼层
这种书写错误,还真难发现,我开始也没找到

但是提醒楼主,用vc++写c程序,关键字有颜色提示的,

写的过程中,碰到关键字就要注意观察颜色有没有变化,没变化证明是书写错误,就要及时改过来、

要不然,写完了在检查,很难找到的
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-10-25 18:55:59 | 显示全部楼层
*﹏LadyG☆ 发表于 2012-10-24 19:21
#include   是多余的
但是int max(int a,int b);不是函数的声明么?

你是用viod main()函数进入的啊,你在函数里面声明了啊,在外面就不用了!
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-10-25 21:39:19 | 显示全部楼层
看看  不发表
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-11-1 10:40:40 | 显示全部楼层
stido改为stdio;ruturn改为return
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-11-1 11:51:40 | 显示全部楼层
  if (a>b) return a;else “→ruturn←” b;       哎  还是多检查检查吧 别一遇到问题就发出来  错 “ruturn”  改 “return”
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-11-1 11:53:12 | 显示全部楼层
还有 文件头。
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-11-1 11:57:57 | 显示全部楼层
恭喜楼主获得“错别字大王”称号。。。。还请再接再励,更上一层楼。。
小甲鱼最新课程 -> https://ilovefishc.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-7-2 20:02

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表