求大侠用c++编写一个程序,要求输入十个学生的姓名,学号和成绩,并输出不及格的姓名,学号和成绩
展开全部
//用结构体做
#include <iostream>
using namespace std;
#include <string>
struct Student{
string name;
int ID;
int score;
}stu[10];
int main()
{
int n = 10;
int i;
for(i = 0; i < n; ++i)
{
cout<<"输入第"<<i+1<<"位同学的名字:\n";
cin>>stu[i].name;
cout<<"学号:";
cin>>stu[i].ID;
cout<<"成绩:";
cin>>stu[i].score;
}
cout<<"不及格的同学有:\n";
cout<<"名字\t学号\t成绩\n";
for(i = 0; i < 10; ++i)
if(stu[i].score < 60)
cout<<stu[i].name<<"\t"<<stu[i].ID<<"\t"<<stu[i].score<<endl;
return 0;
}
#include <iostream>
using namespace std;
#include <string>
struct Student{
string name;
int ID;
int score;
}stu[10];
int main()
{
int n = 10;
int i;
for(i = 0; i < n; ++i)
{
cout<<"输入第"<<i+1<<"位同学的名字:\n";
cin>>stu[i].name;
cout<<"学号:";
cin>>stu[i].ID;
cout<<"成绩:";
cin>>stu[i].score;
}
cout<<"不及格的同学有:\n";
cout<<"名字\t学号\t成绩\n";
for(i = 0; i < 10; ++i)
if(stu[i].score < 60)
cout<<stu[i].name<<"\t"<<stu[i].ID<<"\t"<<stu[i].score<<endl;
return 0;
}
展开全部
#include<stdio.h>
struct student
{
int stuNo;
char stuName[10];
float grade;
};
int main()
{
student stu[10];
int i;
printf("please input 10 student information:\n");
for(i=0;i<10;i++)
{
printf("the number %d:\n",i+1);
printf("name:");
scanf("%s",&stu[i].stuName);
printf("stuNo:");
scanf("%d",&stu[i].stuNo);
printf("Grade:");
scanf("%f",&stu[i].grade);
}
for(i=0;i<10;i++)
{
if(stu[i].grade<60)
printf("\nName:%s\nstuNo:%d\nGrade:%f",stu[i].stuName,stu[i].stuNo,stu[i].grade);
}
return 0;
}
struct student
{
int stuNo;
char stuName[10];
float grade;
};
int main()
{
student stu[10];
int i;
printf("please input 10 student information:\n");
for(i=0;i<10;i++)
{
printf("the number %d:\n",i+1);
printf("name:");
scanf("%s",&stu[i].stuName);
printf("stuNo:");
scanf("%d",&stu[i].stuNo);
printf("Grade:");
scanf("%f",&stu[i].grade);
}
for(i=0;i<10;i++)
{
if(stu[i].grade<60)
printf("\nName:%s\nstuNo:%d\nGrade:%f",stu[i].stuName,stu[i].stuNo,stu[i].grade);
}
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询