注释行总是有错误#include using namespace std;class student{char name[10];double No;float maths,eng,ave,sum;public:student (student *p,int n){for(int i=0;i>(*p).name>>(*p).No>>(*p).maths>>(*p).eng;}float Sum(student *p,int n){for(int i = 0; is
来源:学生作业帮助网 编辑:作业帮 时间:2024/05/15 02:52:27
注释行总是有错误
#include
using namespace std;
class student
{
char name[10];
double No;
float maths,eng,ave,sum;
public:
student (student *p,int n)
{
for(int i=0;i>(*p).name>>(*p).No>>(*p).maths>>(*p).eng;
}
float Sum(student *p,int n)
{
for(int i = 0; isum = p->maths + p->eng;
}
float Ave(student *p,int n)
{
for(int i = 0; iave= p->maths + p->eng;
}
void output(student *p,int n)
{
float ave1=0,ave2=0,sum1=0;
for(int i=0;i
那个错误是说你没有匹配的构造函数.你类的用法完全不对呀.
给你写了一个,你可以参考一下,一个类就是抽象出来的一个事物,不要揉合一大堆乱七八糟的东西在里面.
#include <iostream>using namespace std;
class Student
{
private:
char name[10];
int No;
double maths, eng, avg, sum;
public:
Student(){
cout << "Name, No, Maths, Eng: ";
cin >> name >> No >> maths >> eng;
sum = maths + eng;
avg = sum / 2.0;
}
char* getName(){return name;}
int getNo() {return No;}
double getSum() {return sum;}
double getAvg() {return avg;}
double getMaths() {return maths;}
double getEng() {return eng;}
};
class Students
{
private:
Student *stu;
int size;
public:
Students(int sz)
{
stu = NULL;
size = sz;
stu = new Student[size];
if(!stu)
{
cout << "内存分配失败!" << endl;
}
}
~Students()
{
delete stu;
stu = NULL;
}
public:
double getSum()
{
double sum = 0;
for(int i=0; i<size; i++) sum += stu[i].getSum();
return sum;
}
double getAvg()
{
double avg = 0;
for(int i=0; i<size; i++) avg += stu[i].getAvg();
return avg / size;
}
double getAvgEng()
{
double sum = 0;
for(int i=0; i<size; i++) sum += stu[i].getEng();
return sum / size;
}
double getAvgMaths()
{
double sum = 0;
for(int i=0; i<size; i++) sum += stu[i].getMaths();
return sum / size;
}
void output()
{
cout << "the average score of maths: " << getAvgMaths() << endl;
cout << "the average score of english: " << getAvgEng() << endl;
cout << "the last 20% of the students: " << endl;
showLastStudents();
}
private:
void sortBySumScore()
{
for(int i=0; i<size-1; i++)
{
for(int j=0; j<size-i-1; j++)
{
if(stu[j].getSum() > stu[j+1].getSum())
{
Student t = stu[j];
stu[j] = stu[j+1];
stu[j+1] = t;
}
}
}
}
void showLastStudents()
{
sortBySumScore();
cout << "Name\tNumber\tMaths\tEnglish\n";
for(int i=0; i <= (size * 0.2 - 1); i++)
{
cout << stu[i].getName() << "\t" << stu[i].getNo() << "\t" << stu[i].getMaths() << "\t" << stu[i].getEng() << endl;
}
}
};
int main()
{
int num;
cout<<"Please input the number of the students:";
cin>>num;
Students s(num);
s.output();
return 0;
}
注释行总是有错误#include using namespace std;class student{char name[10];double No;float maths,eng,ave,sum;public:student (student *p,int n){for(int i=0;i>(*p).name>>(*p).No>>(*p).maths>>(*p).eng;}float Sum(student *p,int n){for(int i = 0; is
用c编写一个程序,总是出错,请大家帮忙看下哪里有错误?#include #include #include #include #include int main(){int fd ;if ((fd = serialOpen (/dev/ttyAMA0,115200)) < 0){fprintf (stderr,Unable to open serial device:%s
,strerror (
单链表实现一元多项式相加请帮我看一下这个程序有什么错误,#include #include #include #include #include #include #include #include #include typedef struct LNode{ /*多项式的存储结构定义*/int coef;int expn;struct LNode
看看这个程序中为什么有else的那行总是错误的#include #include using namespace std;int main(){float a,b,c,x1,x2;cin>>a>>b>>c;if(b*b-4*a*c>=0);{x1=(-b+sqrt(b*b-4*a*c))/(2*a);x2=(-b-sqrt(b*b-4*a*c))/(2*a);cout
这个程序用什么调试?有没有错误啊?#include #include #include #include #include #include #include #define BUFFSIZE 150intmain(){ struct sockaddr_in serv; char buf(BUFFSIZE); int sockfd,n; if ((sockfd = socket(PF_INET,SOCK_DGRAM,
请帮忙看下这个题怎么改错,★表示那行有错误,谢谢了! (急)以下程序的功能是删除链表中的一个结点并将结果输出.#include #include #include #include struct station{ char name[8]; struct station *nextSta;};
英语翻译软件总是翻译有错误,什么软件好用呢?
#include 或者#include 和或者#include #include是什么意思 为什么#include后面的 英文总是变 是不是在xp下 就打#include 而dos下 就打#include
C语言 求1-100间的素数.如果有别的方法 希望有注释.#include main(){int i,j;for(i=3;i
..有两个错误在下面#include #include int sum( int b[ ],int n ){ int i,s = 0;for ( i=0; i
#include 和#include 和#include 是什么意思,有什么作用.
include in和include有什么区别?
#include double fun(double a1,double a2,int b) {switch(b) {case 0:return (a1+a2); case 1:r请高手添加行注释啊!
孔孟论学注释有没有
的注释有吗?
虽有佳肴 注释
#include 有什么用
vs2008中文版为什么写中文注释时,文字下面会有红色错误提示波浪线!如何去掉?