写一个c 程序 Write a C program
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/07/14 18:58:41
写一个c 程序 Write a C program
Write a C program that receives from the command line a student ID (SXXXXX) to be used as a reference.Then the program asks the user to introduce the information about the results obtained by a set of students in the final examination (maximum 100,however,the user may introduce a lower number of entries).The input format must be the following:
NAME LASTNAME student_ID MARK
In the case the reference ID is introduced in the provided list,the program must compute how many students obtained lower and higher marks compared to the reference one.
Write a C program that receives from the command line a student ID (SXXXXX) to be used as a reference.Then the program asks the user to introduce the information about the results obtained by a set of students in the final examination (maximum 100,however,the user may introduce a lower number of entries).The input format must be the following:
NAME LASTNAME student_ID MARK
In the case the reference ID is introduced in the provided list,the program must compute how many students obtained lower and higher marks compared to the reference one.
#include<iostream>
#define MAXSIZE 100
using namespace std;
struct Student
{
char name[20];
char last_name[20];
int ID;
int mark;
};
class list
{
private:
Student stu[MAXSIZE];
int len;
public:
void input();
void sort();
};
void list::input()
{
cout<<"How many students do you want to input?"<<endl;
cin>>len;
for(int i=1;i<=len;i++)
{
cout<<"Input name"<<endl;
cin>>stu[i].name;
cout<<"Input last_name"<<endl;
cin>>stu[i].last_name;
cout<<"Input ID"<<endl;
cin>>stu[i].ID;
cout<<"Input mark"<<endl;
cin>>stu[i].mark;
}
}
void list::sort()
{
int ID1,lower=0,higher=0;
cout<<"Please Input the reference ID(1<=ID<=The total number of Student)"<<endl;
cin>>ID1;
for(int i=1;i<=len;i++)
{
if(stu[ID1].mark>stu[i].mark)
lower++;
if(stu[ID1].mark<stu[i].mark)
higher++;
}
cout<<"There're "<<lower<<" Students' mark lower than reference ID's Student."<<endl;
cout<<"There're "<<higher<<" Students' mark higher than reference ID's Student."<<endl;
}
void main()
{
list stu;
stu.input();
stu.sort();
}Successful operation in VC6.0
#define MAXSIZE 100
using namespace std;
struct Student
{
char name[20];
char last_name[20];
int ID;
int mark;
};
class list
{
private:
Student stu[MAXSIZE];
int len;
public:
void input();
void sort();
};
void list::input()
{
cout<<"How many students do you want to input?"<<endl;
cin>>len;
for(int i=1;i<=len;i++)
{
cout<<"Input name"<<endl;
cin>>stu[i].name;
cout<<"Input last_name"<<endl;
cin>>stu[i].last_name;
cout<<"Input ID"<<endl;
cin>>stu[i].ID;
cout<<"Input mark"<<endl;
cin>>stu[i].mark;
}
}
void list::sort()
{
int ID1,lower=0,higher=0;
cout<<"Please Input the reference ID(1<=ID<=The total number of Student)"<<endl;
cin>>ID1;
for(int i=1;i<=len;i++)
{
if(stu[ID1].mark>stu[i].mark)
lower++;
if(stu[ID1].mark<stu[i].mark)
higher++;
}
cout<<"There're "<<lower<<" Students' mark lower than reference ID's Student."<<endl;
cout<<"There're "<<higher<<" Students' mark higher than reference ID's Student."<<endl;
}
void main()
{
list stu;
stu.input();
stu.sort();
}Successful operation in VC6.0
写一个c 程序 Write a C program
C语言程序write a program to display a Christmas tree
write a C program C语言程序设计 在线等.拜托谢谢
关于C语言的一道题原题:Write a program that requests a type double numb
C语言字符串计数Write a program that reads an English statement from
unable to write to C:\Program Files\WdMai\config.
求大神写一个c语言程序,
帮我写一个C语言程序.
this is a c program什么意思
用C语言写一个计算A+B的简单程序
C++:abnormal program termination
如何用C语言 写一个随机数生成器的程序