Skip to content

Instantly share code, notes, and snippets.

@hansen033
Last active December 7, 2017 12:01
Show Gist options
  • Save hansen033/6729d1f385fa2026aeec2af09e386ae9 to your computer and use it in GitHub Desktop.
Save hansen033/6729d1f385fa2026aeec2af09e386ae9 to your computer and use it in GitHub Desktop.
2017/11/23 幾分鐘前交的搞錯題目
#include <iostream>
using namespace std;
int main()
{
int AL, men;
cout << "請輸入要算{幾個數}的平均數:\n";
cin >> men;
int num[men];
cout << "請輸入要算的" << men << "個數的平均數的數值(小數點會不見):\n";
for( int t = 0 ; t < men ; t ++ ){
cin >> num[t];
}
for( int t = 0 ; t < men ; t ++ ){
AL += num[t];
}
cout << "\n這10個數的平均數是:" << AL / men;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment