C++程序问题,请高手帮忙看看。不胜感激。目标有:用键盘输入身高、体重、学号;输出最高学生和最瘦学生的

作者&投稿:虿波 (若有异议请与网页底部的电邮联系)
求一个c++程序 要求输入身高和体重,输出BMI值(身体质量指数)~

#include
using namespace std;
cout << "Enter weight in pounds:";
double weight;
cin >> weight;
const double KILOGRAMS_PER_POUND = 0.45359237;
double bmi = weightInKilongrams /
(heightInMeters*heightInMeters);
cout << "BMI is" << bmi << endl;
if (bmi < 18.5)
cout << "Overweight" << endl;
else

起源
C++程序源于C语言,还记得很久以前学习C语言的时光(那是一段快乐而充实的时光),可是现在学习C++,并不是在C的基础上加上了类而已,如果这样认为,我们是耍不好C++的。因此,C++绝不是C的升级或扩充,我们应该把C++当作一门新语言来学习(C++之父Bjarne Stroustrup语)。

#include#includestruct studata{ char *id; char *name; char *cj;};#define stuSize 3//学生个数#define idSize 20//学生编号字符数#define nameSize 20//学生姓名字符数#define cjSize 3//学生成绩字符数int main(){ struct studata stus[stuSize]; int i=0; while(i<stuSize) { printf("请输入学生 学号 姓名 成绩 "); stus[i].id=malloc(sizeof(idSize)); stus[i].name=malloc(sizeof(nameSize)); stus[i].cj=malloc(sizeof(cjSize)); scanf("%s%s%s",stus[i].id,stus[i].name,stus[i].cj); i++; } i=0; while(i<stuSize) { printf("学号: %s 姓名:%s 成绩:%s
",stus[i].id,stus[i].name,stus[i].cj); i++; } return 0;}

楼主,你的错误实在太多,希望编程的时候细心点,你的很多错误都是拼写错误,改过代码如下。
#define N 10

#include <stdio.h>
#include <math.h>
float maxheight(float height[])
{
int i;
int s=0;
float maxheight;
maxheight=height[0];
for(i=1;i<N;i++)
{
if(height[i]>maxheight)
s=i;
maxheight=height[i];
}
printf("The height of the highest student is:%f",maxheight);
printf("the highest student's mumber is:%d\n",s);
return maxheight;
}
float minweight(float weight[])
{
int i;
int r=0;
float minweight;
minweight=weight[0];
for (i=1;i<N;i++)
{
if(weight[i]<minweight)
r=i;
minweight=weight[i];
}
printf("The weight of the lightest student is:%f",minweight);
printf(" the lightest student's number is:%d\n",r);
return minweight;
}
void main (void)
{
int i;
float height[N],weight[N];
int student_number[N];
for (i=0;i<N;i++)
{
printf("please input students’ height and weight:\n");
scanf("%f%f",&height,&weight);
printf("please input sthdent's number:\n");
scanf("%d",&student_number[i]);
}
return ;

float maxh,minw;
maxheight(height);
minweight(weight);
float Square[N], BIMvalue[N];
int j;
for(j=0;j<N;j++)
{
Square[j]=height[j]*height[j];
BIMvalue[j]=weight[j]/Square[j] ;
printf("this student's BIMvalue is:%f",BIMvalue[j]);
printf("this student's number is:%d\n",student_number[j]);
}
int a=0,b=0,c=0,l=0;
while (l<N)
{
if (BIMvalue[l]>25)
{
printf("this student is overwent");
printf("this student's number is:%d\n",student_number[l]);
a++;
}
else
if(BIMvalue[j]>18)
{
printf("this student is of normal weight");
printf("this student's number is:%d\n",student_number[l]);
b++;
}
else
{
printf("this student is underweight");
printf("this student's number is:%d\n",student_number[l]);
c++;
}

l++;
}
printf("The number of overweight students is:%d\n",a);
printf("The number of normal weight students is:%d\n",b);
printf("the number of underweight students is:%d\n",c);
float u;
u=b/N;
printf("The proportion of normal weight students:%f\n",u);
return;

int z=0,m=0,n=0;
float *p=BIMvalue;
float maxBIMvalue;
maxBIMvalue=BIMvalue[0];
for(z=0;z<N;z++)
{
if(BIMvalue[z]>maxBIMvalue)
maxBIMvalue=BIMvalue[z];
m=z;
z++;
}
printf("this student's number is:%d",student_number[m]);
printf("the maxBIMvalue is:%f\n",*(p+m));
float minBIMvalue;
minBIMvalue=BIMvalue[0];
for(z=0;z<N;z++)
{
if(BIMvalue[z]<minBIMvalue)
n=z;
minBIMvalue=BIMvalue[z];
}
printf("this student's number is:%d",student_number[n]);
printf("the minBIMvalue is:%f\n",*(p+n));
}

发个

两道C语言看程序谢结果题不会,哪位高手能帮忙解释一下,直接给答案就算...
答:第一题:输出结果:04321 执行过程:从 main() 函数开始执行,执行到 f(12340),进入函数 f(int x) 中,此时参数 x 的值为12340 不等于 0 ,进入 if (x) 语句,执行 putchar (x % 10 + '0'),此时,x % 10 的值为 0 , 0 + '0' 为 '0' (因为字符 '0' ~'9' 的 ASCII ...

C语言问题,请高手帮忙,急!
答:在C语言中,这是一个语法错误。在运行程序时发现了一个问题,总是提示一个错误:error C2143: syntax error : missing before type。解决方法如下:把所有变量的声明放在可执行代码之前。出现此问题的原因在于:将文件保存成了 .c 格式。如果是cpp格式就能正常编译。改成.cpp就可以正常运行,和你变量...

各位知友,本人新学C语音。碰到一个不复杂的程序问题,对运行结果有疑问...
答:碰到一个不复杂的程序问题,对运行结果有疑问,题目如下,求高手解惑: #include<stdio.h>voidmain(){inta,b,c,d;a=1;b=2;c=(a++)+(a++)+(a++);d=(++b)+(++b)+(++b);printf("c=%d,d=%d\n",c,d);printf("a=%d,b=%d\n",a,b);}本人得出结果:c=3,d=15a=4,b=5v... #include<...

关于C语言编写程序的一个疑问 高手帮忙看看我的程序哪错了
答:看了你的代码觉得,你在C语言的语法规则上还有待提高啊,在此举出你所给出的代码的若干错误。首先,你的代码不完整。第9、11、13行要定义三个100行的二维字符数组,如果仅仅是类似char adj[100][12]={"开心的"}的定义;这样adj[1]到adj[99]这99个词都会是空值(ASCII码为0),若用printf()函...

帮忙看一个C程序问题
答:symbol _workover是说你的程序里出现了没有对应模块的标识符,只要修改 一下就可以了*/ /*该程序作为考试题还可以,如果是实际项目开发使用,请使用有实际含义的符合一定标准(比如匈牙 利命名法)的命名方法,以便于维护和理解*/ /*上述是个人对C语言变量作用域的理解和粗略判断,仅供参考*/ ...

一个c++程序 麻烦高手帮忙看下错在哪里
答:你的程序的crash问题原因就一个:car构造函数的默认参数错了 你是:car (float =0.0,char ='X',int =0,char * ='\0');应该:car (float =0.0,char ='X',int =0,char * = “”);'\0' 确实是字符串结尾字符,但是你这里参数类型是char* ,所以其实你设置的相当于 char* = 0x...

关于C语言指针的问题,希望高手帮忙解答一下
答:你要明白,指针变量有两个相关的值,一个是指针变量本身的内存地址,一个是该内存地址存储的数据,是另一个变量的地址。如:int *p;//定义一个指针变量,既然是变量,它本身就有地址,还没赋值,它里面的数据不确定。所以*p=5;是错误的,还没初始化,指向的内存地址不确定,要把5存储到哪里的内存...

请教C程序高手一些问题,望能解答...谢谢!!
答:4.函数delete_string( char s[ ],char c)将字符串s中所出现的与变量c相同的字符删除,请填空。delete_string(char *s, char ch) /*定义外部函delete_string*/ {int i,j;for (i=j=0;*(s+i)!='\0';i++)if (*(s+i)!=ch) ___;(s+j)='\0';} 5.下面程序段将输出 comput...

C++程序问题,哪位高手帮帮忙看下。有一个错误invalid conversion from...
答:printf("%c ",t->data);inorder1(t->right);} } void inorder2(bitree *b){ bitree *St[MaxSize],*p;int top=-1;p=b;while (top>-1 || p!=null){ while (p!=null){ top++;St[top]=p;p=p->left;} if (top>-1){ p=St[top];top--;printf("%c ",p->da...

一个C语言程序问题,看晕了,求大神详解
答:第二次循环: 条件1不成立。条件2成立,x=3。执行continue,忽略语句3,执行下个循环。第三次循环: 条件1不成立。条件2不成立,执行3,x=0, y=3 第四次循环: 条件1不成立。条件2成立,x=5。执行continue。忽略3,执行下一个循环。第五次循环: 条件1不成立。条件2不成立,执行3,x=2, y...