#27681: CPP


11030067@mail.hpsh.tp.edu.tw (和平110級鄧雨珊)

學校 : 臺北市立和平高級中學
編號 : 163096
來源 : [61.64.210.174]
最後登入時間 :
2022-10-23 16:54:59
d010. 盈數、虧數和完全數 -- Sagit's C++ 程式設計 | From: [27.105.52.161] | 發表日期 : 2021-10-23 12:00

#include <iostream>
using namespace std;

int main(){
int n, s;
while (cin >> n){
s=0;
for (int i=1; i<n; i++){
if (n%i==0){
s+=i;
}
}
if (s<n){
cout <<"虧數"<<endl;
}
else if (s==n){
cout <<"完全數"<<endl;
}
else {
cout <<"盈數"<<endl;
}
}
}
 
ZeroJudge Forum