fork download
  1.  
  2. #include<iostream.h>
  3. #include <stdlib.h>
  4. #include<iomanip.h>
  5. int main(void)
  6. { char s1;
  7. int i,s[100][4],n,j,s2,s3,s4;
  8. float a[100];char ch[100];
  9.  
  10. {
  11. cout<<"班級人數?";
  12. cin>>n;
  13. }
  14.  
  15. for (i=0;i<n;i++)
  16. {
  17. cout<<"輸入三成績\n";
  18. cin>>s[i][0]>>s[i][1]>>s[i][2];
  19. }
  20.  
  21. for (i=0;i<n;i++)
  22. {
  23. s[i][3]=s[i][0]+s[i][1]+s[i][2];
  24. a[i]=s[i][3]/3.0;
  25.  
  26. if (a[i]>=60)
  27. ch[i]='P';
  28. else
  29. ch[i]='F';
  30. }
  31. cout<<" 國文 英文 數學 加總 平均 "<<endl<<"==============================\n";
  32.  
  33. for (i=0;i<n;i++)
  34. cout<<setw(5)<<s[i][0]<<setw(5)<<s[i][1]<<setw(5)<<s[i][2]<<setw(5)<<s[i][3]
  35. <<setw(8)<<setprecision(2)<<a[i]<<" "<<ch[i]<<endl<<endl;
  36.  
  37. cout<<"==========================================\n";
  38.  
  39.  
  40. //quest2
  41. s2=0,s3=0,s4=0;
  42. for (i=0;i<n;i++)
  43. {
  44. s2=s2+s[i][0];s3=s3+s[i][1];s4=s4+s[i][2];
  45. }
  46. cout <<"tal"<<setw(2)<<s2<<setw(5)<<s3<<setw(5)<<s4<<endl;
  47. s2=s2/n;s3=s3/n;s4=s4/n ;
  48. cout <<"avg"<<setw(2)<<s2<<setw(5)<<s3<<setw(5)<<s4<<endl;
  49. cin>>s1;
  50.  
  51. return 0;
  52. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:2:21: error: iostream.h: No such file or directory
prog.cpp:4:20: error: iomanip.h: No such file or directory
prog.cpp: In function ‘int main()’:
prog.cpp:11: error: ‘cout’ was not declared in this scope
prog.cpp:12: error: ‘cin’ was not declared in this scope
prog.cpp:17: error: ‘cout’ was not declared in this scope
prog.cpp:18: error: ‘cin’ was not declared in this scope
prog.cpp:31: error: ‘cout’ was not declared in this scope
prog.cpp:31: error: ‘endl’ was not declared in this scope
prog.cpp:34: error: ‘setw’ was not declared in this scope
prog.cpp:35: error: ‘setprecision’ was not declared in this scope
prog.cpp:46: error: ‘setw’ was not declared in this scope
prog.cpp:49: error: ‘cin’ was not declared in this scope
prog.cpp:7: warning: unused variable ‘j’
stdout
Standard output is empty