✔ 最佳答案
因為沒 visual studio, 所以, 以下 code 只可以作參考:
#include <stdio.h>int main () {
int num = 17; /* the number wants to find its factors */
int count = 0; /* count of number of factor */
int factor[255]; /* use for store a limit number of factors */
/* if use a stack or link list may be stored */
/* unlimited number of factors */
int i; /* counter index */
/* find the factor(s) of num and store in the factor[] array */
for (i=1; i<=num; i++) {
if ( num % i == 0 ) {
factor[count] = i;
count++;
}
}
/* print the result */
printf("The factor(s) of %d is/are:\n", num);
for (i=0; i<count; i++) {
printf("%d ", factor[i]);
}
return 0;
}
以下是 output screen, compiled with Dev-C++ 4.9.9.2:
圖片參考:
http://imgcld.yimg.com/8/n/HA00458611/o/701010230173313873379410.jpg