fork download
  1. /* package whatever; // don't place package name! */
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int score[100] = {0};
  8. int a = 0, sum = 0, count = 0, maxi = score[a], min = score[a];
  9. cout << "輸入成績:" << endl;
  10. while (cin >> score[a])
  11. {
  12. if (score[a] < 0 || score[a] >101)
  13. {
  14. cout << "超過範圍" << endl;
  15. cout << "重新輸入成績:" << endl;
  16. }
  17. else if (score[a] >= 0 && score[a] < 101)
  18. {
  19. cout << "輸入成績:" << endl;
  20. count++;
  21. sum = sum + score[a];
  22. }
  23. else if (score[a] == 101)
  24. {
  25. for (int i = 0; i < count; i++)
  26. {
  27. for (int j = i + 1; j < count; j++)
  28. {
  29. if (score[i] < score[j])
  30. {
  31. int temp = score[i];
  32. score[i] = score[j];
  33. score[j] = temp;
  34.  
  35. }
  36. }
  37. //cout << score[1];
  38. }
  39.  
  40. cout << "總分:" << sum << endl;
  41. cout << "平均:" << (float)(sum) / (count) << endl;
  42. for (int k = 0; k < count; k++)
  43. {
  44. cout << score[k]<<endl;
  45. }
  46. }
  47. }
  48. system("pause");
  49. return 0;
  50. }
  51.  
Success #stdin #stdout #stderr 0.01s 5324KB
stdin
Standard input is empty
stdout
輸入成績:
stderr
sh: 1: pause: not found