2025-03-06 22:45:14 +08:00

23 lines
432 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*-------------------------------------------------------
编程判断m是否素数,m由键盘输入。(使用for循环
-------------------------------------------------------*/
#include <stdio.h>
main()
{
int m,i;
printf("请输入一个正整数 :");
scanf("%d",&m);
/**********Program**********/
for(i=2;i<m;i++){
if(m%i==0){
break;
}
}
/********** End **********/
if(i==m)
printf("%d是素数\n",m);
else
printf("%d不是素数\n",m);
}