{int num; char name[20]; double score; }; int main()
{student stud[3]={1001,\ char c[50]; int i;
ostrstream strout(c,50); for(i=0;i<3;i++)
strout< cout<<\ istrstream strin(c,50); for(i=0;i<3;i++) strin>>stud1[i].num>>stud1[i].name>>stud1[i].score; cout<<\ for(i=0;i<3;i++) cout< #include {int num; char name[20]; double score; }; int main() {int i; student stud[3]={1001,\ char c[50]; strstream strio(c,50,ios::in|ios::out); for(i=0;i<3;i++) strio< cout<<\ for(i=0;i<3;i++) strio>>stud1[i].num>>stud1[i].name>>stud1[i].score; cout<<\ for(i=0;i<3;i++) cout< 第八章 1: #include using namespace std; double q(double,double,double); void main() {double a,b,c,p,x1,x2; cout<<\ cin>>a>>b>>c; p=-b/(2*a); try {x1=p+q(a,b,c); x2=p-q(a,b,c); cout<<\ } catch(double d) {cout<<\ cout<<\ } double q(double a,double b,double c) {double disc; disc=b*b-4*a*c; if (disc<0) throw disc; return sqrt(disc)/(2*a); } 2: #include class Student {public: Student(int n,string nam) {cout<<\ num=n;name=nam;} ~Student(){cout<<\ void get_data(); private: int num; string name; }; void Student::get_data() {if(num==0) throw num; else cout< void fun() {Student stud1(1101,\ (); try {Student stud2(0,\ (); } catch(int n) {cout<<\ } int main() {cout<<\ cout<<\ fun(); cout<<\ return 0; } 3: //main file #include using namespace std; using namespace student1; int main() {Student stud1(1001,\ (); student2::Student stud2(1102,\ (); return 0; } //,文件名为 #include