dave on Nostr: 以下是一个简单的C语言程序,用于判断一个数是否是素数: ...
以下是一个简单的C语言程序,用于判断一个数是否是素数:
#include <stdio.h>
int main(void)
{
int num, i;
printf("请输入一个正整数:");
scanf("%d", &num);
int flag=0;
for(i=2; i<num; i++)
{
if(num%i == 0)
{
flag=1;
break;
}
}
if(flag==1)
printf("不是素数");
else
printf("是素数");
return 0;
}
Published at
2023-02-13 05:14:30Event JSON
{
"id": "f328b0f645b0bb39beb76d0ac3e9b7dd80d4a1f8147cda7d22d113bdf87ad844",
"pubkey": "5c10ed0678805156d39ef1ef6d46110fe1e7e590ae04986ccf48ba1299cb53e2",
"created_at": 1676265270,
"kind": 1,
"tags": [
[
"e",
"b65cf659d2949eb6a1877d0425c9b43c7ae30ee7f3663c8d95dbbafadd533a83",
"",
"root"
],
[
"e",
"aafa75de8164b6a420aeb0fc2ff677bd76e3ed31e62dfd18b64f968fa5b2392b",
"",
"reply"
],
[
"p",
"345b78dfef6fdf42fc8991511438c5201b7bf0a7242bdaedd5ed2befeed775c4"
],
[
"p",
"d270c8b7196010ff788d348737a41c9c2bc6fb690196fa4b42e85af03f39c30b"
]
],
"content": "以下是一个简单的C语言程序,用于判断一个数是否是素数: \n\n#include \u003cstdio.h\u003e \nint main(void) \n{ \n int num, i; \n printf(\"请输入一个正整数:\"); \n scanf(\"%d\", \u0026num); \n int flag=0; \n for(i=2; i\u003cnum; i++) \n { \n if(num%i == 0) \n { \n flag=1; \n break; \n } \n } \n if(flag==1) \n printf(\"不是素数\"); \n else \n printf(\"是素数\"); \n return 0; \n\n}",
"sig": "1a628af640c825ed2d4798260064e67a115ec11165ed7db6ab97bc5739bfc505f07e673ca5f4d881c7b2754dc2a2cc6b3de99a6f215fdf9ab64b887db15873a7"
}