| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 600 人关注过本帖
标题:菜鸟级求大神看下这段代码有什么问题
只看楼主 加入收藏
yue635917957
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2015-11-16
收藏
 问题点数:0 回复次数:7 
菜鸟级求大神看下这段代码有什么问题
#include<stdio.h>
main()
{
    float radius,height,vol;
    float volume(float,float);
    printf("Please input the radius and height:\n");
    scanf(%f %f,&radius,&height);
    vol=volume(radius,height);
    prinf("volume=%f\n",vol);
}
float volume(float r,float h)
{
    float temp;
    float pi=3.1415926;
    temp=pi*r*r*h;
    return temp;
}
搜索更多相关主题的帖子: return volume 
2015-11-16 15:46
天之翎
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2015-11-16
收藏
得分:0 
scanf函数的""呢?还有%f与%f间有空格的话输入时要加空格
2015-11-17 00:06
lzl123321
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:41
专家分:148
注 册:2015-10-15
收藏
得分:0 
以下是引用yue635917957在2015-11-16 15:46:25的发言:

#include<stdio.h>
main()
{
    float radius,height,vol;
    float volume(float,float);
    printf("Please input the radius and height:\n");
    scanf(%f %f,&radius,&height);
    vol=volume(radius,height);
    prinf("volume=%f\n",vol);
}
float volume(float r,float h)
{
    float temp;
    float pi=3.1415926;
    temp=pi*r*r*h;
    return temp;
}

主函数声明调用函数,省略形参不确定是否会有点问题,也没有查到省略形参的用法,所查到的用法一般都会跟后面定义的函数保持一致的,坐等高手指点~~
2015-11-17 06:42
邹阳
Rank: 6Rank: 6
等 级:侠之大者
威 望:4
帖 子:124
专家分:402
注 册:2015-10-8
收藏
得分:0 
#include<stdio.h>
main()
{
    float radius,height,vol;
    float volume(float,float);
    printf("Please input the radius and height:\n");
    scanf(%f %f,&radius,&height);
    vol=volume(radius,height);
    prinf("volume=%f\n",vol);
}
float volume(float r,float h)
{
    float temp;
    float pi=3.1415926;
    temp=pi*r*r*h;
    return temp;
}

请注意代码书写规范!

I'm a new comer
2015-11-19 12:57
winner1995
Rank: 2
等 级:论坛游民
帖 子:64
专家分:41
注 册:2015-10-11
收藏
得分:0 
你用了数学中的计算
应该少了一个头文件#include<math.h>试下吧

唯望君安~
2015-11-19 13:02
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:0 
以下是引用winner1995在2015-11-19 13:02:48的发言:

你用了数学中的计算
应该少了一个头文件#include<math.h>试下吧



不要瞎说  请问 哪条语句需要引用 math.h

DO IT YOURSELF !
2015-11-19 13:16
huorhway
Rank: 1
等 级:新手上路
帖 子:7
专家分:8
注 册:2015-11-19
收藏
得分:0 
楼上各位说的书写规范,除了忘加""以外,还有printf拼成了print,这个程序在C语言中运行一遍,就能看到报错,应该不难发现错误。
2015-11-19 14:55
brokenheart
Rank: 2
等 级:论坛游民
帖 子:64
专家分:25
注 册:2015-11-7
收藏
得分:0 
#include<stdio.h>
int main()
{
    float radius,height,vol;
    float volume(float r,float h);
    printf("Please input the radius and height:\n");
    scanf("%f,%f",&radius,&height);
    vol=volume(radius,height);
    printf("volume=%f\n",vol);
        return 0;
}
float volume(float r,float h)
{
    float temp;
    float pi=3.1415926;
    temp=pi*r*r*h;
    return temp;
}
注意书写格式
2015-11-21 09:48
快速回复:菜鸟级求大神看下这段代码有什么问题
数据加载中...
 
   



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

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