#include <iostream>
#include <string>
using namespace std;
class Student
{
private:
string SName;
string SNo;
string SScore[10];
public :
void init();
void print();
};
void Student::init()
{
cout<<"请输入学生姓名:";
cin>>this->SName;
cout<<"学号:";
cin>>this->SNo;
cout<<"各科成绩:";
for(int i=0;i<5;i++)
{
cin>>this->SScore[i];
}
}
void Student::print()
{
cout<<"学生信息:姓名:"<<SName<<"\t学号:"<<SNo<<"\t各科成绩";
for(int i=0;i<5;i++)
{
cout<<SScore[i]<<"\t";
}
cout<<endl;
}
int main()
{
Student s;
s.init();
s.print();
return 0;
},我编的只能够输入一个学生的信息,怎么输入多个学生信息,并求出最高分,输出最高分学生的姓名和学号!求高手帮忙啊
error C2374: 'i' : redefinition; multiple initialization
see declaration of 'i'
e redefinition; multiple initialization
see declaration of 'i'
fatal error C1004: unexpected end of file found,帮å¿è§£å³ä¸ä¸å§
ï¼è°¢è°¢
int main() {
int i;
Student s[5];
string name,no;
double score[5];
for(i = 0; i > name;
cout > no;
cout > score[0];
cout > score[1];
cout > score[2];
cout > score[3];
cout << endl;
s[i] = Student(name,no,score);
}
cout << "å§å\tå¦å·\té«æ°\tè±è¯\tç¼ç¨\t硬件\t\n";
for(i = 0; i < 48; ++i) cout << "*";
cout << endl;
for(i = 0; i < 5; ++i) s[i].Show();
cout << endl;
return 0;
}
ä½ å¯ä»¥å帮å¿æ¹ä¸ä¸åï¼åè½å®ç°(1)è¾åºæ»åæé«çå¦ççå§ååæ»åæ°(2)è¾åºæ¯é¨è¯¾åç§åæé«çå¦ççå¦å·ååæ°ã(è¿éå设æ5个å¦çï¼æ¯ä¸ªå¦ççå¦å·åæ绩ä»é®çè¾å ¥).å ³é®ä½ç½®æ³¨éä¸ä¸ï¼æ好好å¦ä¹ ä¸ä¸ï¼è°¢è°¢
追çint main() {
int i,k;
Student s[5];
string name,no;
double score[5],max;
for(i = 0; i > name;
cout > no;
cout > score[0];
cout > score[1];
cout > score[2];
cout > score[3];
cout max) {
max = s[i].GetAverage();
k = i;
}
}
cout << endl;
cout << "æ»åæé«çæ¯:\n";
s[k].Show();
return 0;
}
error LNK2001: unresolved external symbol _WinMain@16
Debug/cxc.exe : fatal error LNK1120: 1 unresolved externals
æ§è¡ link.exe æ¶åºé.
è¿é®é¢å解å³åï¼è¿ææ¯åç§æé«çåæ±åï¼ä¹éè¦è¾åºæ¯ç§æé«ååãä½ å¸®å¸®å¿ï¼é常æè°¢
帮忙写到程序里可以吗?我不知道写哪好啊?谢谢了
你帮忙完整的写一遍把?我不太会。。。谢谢
追答#include
using namespace std;
#include
#include
using namespace std;
//int find (Student);
class Student
{
private:
string SName;
string SNo;
int SScore[10];
int sum;
public :
void init();
void print();
};
void Student::init()
{
cout>this->SName;
cout>this->SNo;
cout>this->SScore[i];
}
for(int i = 0;i< 10;i++)
{
sum = SScore[i] + sum;
}
}
void Student::print()
{
cout<<"学生信息:姓名:"<<SName<<"\t学号:"<<SNo<<"\t各科成绩";
for(int i=0;i<5;i++)
{
cout<<SScore[i]<<"\t";
}
cout<<endl;
}
int find (Student);
int main()
{
//Student s;
// s.init();
//s.print();
int maxSum;
Student students[3];
for(int i = 0; i < 3; i++)
{
students[i].init();//input the students infomation
//students[i].printf();
}
maxSum = find (students[]);
cout << " the higthest score is "<< maxSum<<endl;
return 0;
}
int find (students)
{
int temp;
for (int i = 0; i < 10 ; i ++)
{
if (students[i].sum<students[i+1].sum)
{ temp = students[i+1].sum;
}
}
return temp;
}
还有编译错误,你自己改改吧,问题不大了,我得睡觉了,你要改不了,明天再说,我也是学生哦,学软件的,C++结课了,忘得差不多了!嘻嘻嘻
你在帮我解决一下?可以不?谢谢、、、、、、要求总分最高的和每科最高分都要输出来啊,你帮帮我看看把,顺便关键位置注释一下,我好好学习学习。