送分题,照着要求做就行了
#include <stdio.h>
#include<math.h>int nums[100];
int perfect[100];
void output()
{printf("PERFECTION OUTPUT\n");for (int i = 0; i < 100; i++){if (nums[i] != 0){int factors[60000] = { 0 };int k = 0;for (int j = 1; j < nums[i]; j++){if (nums[i] % j == 0){factors[k] = j;k++;}}int sum = 0;for (int m = 0; m < 60000; m++){if (factors[m] > 0){sum += factors[m];}else break;}if (sum == nums[i])perfect[i] = 2;else if (sum < nums[i])perfect[i] = 1;elseperfect[i] = 3;}elsebreak;}for (int a = 0; a < 100; a++){int bits[6] = { 0, 10, 100, 1000, 10000, 100000 };for (int z = 0; z < 5; z++){if (nums[a]>bits[z] && nums[a] < bits[z + 1]){for (int x = 0; x < 5 - z - 1; x++)printf(" ");break;}}if (perfect[a] == 3)printf("%d ABUNDANT\n", nums[a]);else if (perfect[a] == 2)printf("%d PERFECT\n", nums[a]);else if (perfect[a] == 1)printf("%d DEFICIENT\n", nums[a]);else if (perfect[a] == 0) break;}printf("END OF OUTPUT\n");
}
int main()
{int num;int i = 0;while (scanf("%d", &num)){if (num == 0){break;}nums[i] = num;i++;}output();return 0;
}