注册 登录
编程论坛 VC++/MFC

各位大神帮帮忙,为什么while循环不了

nan1888 发布于 2011-11-17 16:54, 795 次点击
#include<iostream>
using namespace std;
struct student
{char name[30];
int num;
int score;
};
int main()
{student stu;
int k;
    cout<<"输入学生的相关信息\n"<<endl;
    cin>>k;
while (k>0);
{cout<<"学号"<<endl;
cin>>stu.num;
cout<<"姓名"<<endl;
cin>>stu.name;
cout<<"成绩"<<endl;
cin>>stu.score;
cin>>k;}
}
4 回复
#2
staler2011-11-17 22:27
while(k>0)后面有个分号去掉!


[ 本帖最后由 staler 于 2011-11-17 22:30 编辑 ]
#3
staler2011-11-17 22:33
c++里面分号和大括号代表一个语句完了
 不是while没循环
而是你没有循环体
#4
yuaniao2011-11-17 22:46
#include<iostream>
using namespace std;
struct student
{char name[30];
int num;
int score;
};
int main()
{student stu;
int k;
    cout<<"输入学生的相关信息\n"<<endl;
    cin>>k;
while (k>0)//;
{cout<<"学号"<<endl;
cin>>stu.num;
cout<<"姓名"<<endl;
cin>>stu.name;
cout<<"成绩"<<endl;
cin>>stu.score;
cin>>k;}
}
#5
nan18882011-11-18 14:15
谢谢。。。。居然看不到那个分号了
1