程式碼:
#include<iostream>
using namespace std;
int sum(int a, int b, int c)
{
return a + b + c;
}
int average(int a, int b, int c)
return (a + b + c) / 3;
void main()
int i;int a[5],b[5],c[5];
for (i = 0; i < 5; i++)
cout << "請輸入第"<<i+1<<"位語數外三門成績:" << endl;
cin >> a[i]>>b[i]>>c[i];
cout << "語數外三門總成績:" << sum(a[i], b[i], c[i]) << " 平均:" << average(a[i], b[i], c[i]) << endl;
程式碼:
#include<iostream>
using namespace std;
int sum(int a, int b, int c)
{
return a + b + c;
}
int average(int a, int b, int c)
{
return (a + b + c) / 3;
}
void main()
{
int i;int a[5],b[5],c[5];
for (i = 0; i < 5; i++)
{
cout << "請輸入第"<<i+1<<"位語數外三門成績:" << endl;
cin >> a[i]>>b[i]>>c[i];
cout << "語數外三門總成績:" << sum(a[i], b[i], c[i]) << " 平均:" << average(a[i], b[i], c[i]) << endl;
}
}