要求編寫子函數(shù)prime?
#include <stdio.h>int prime(int m){int i,k=0;for(i=2;i<m;i++)if(m%i==0) break;if(i>=m) k=1;return k;}void main(){int m,k,n=0;for(m=2;m<=100;m++){k=prime(m);if(k){printf("%-4d",m);n++;if(n%5==0) printf("\n");}}}
要求編寫子函數(shù)prime?
#include <stdio.h>int prime(int m){int i,k=0;for(i=2;i<m;i++)if(m%i==0) break;if(i>=m) k=1;return k;}void main(){int m,k,n=0;for(m=2;m<=100;m++){k=prime(m);if(k){printf("%-4d",m);n++;if(n%5==0) printf("\n");}}}