c语言小程序

2024-09-28 15:42:15 11 Admin
免费网站建设

 

#include

 

int main() {

// 打印1000个字母'A'

int count = 0;

while (count < 1000)="">

printf("A");

count++;

}

// 打印1000个数字

count = 0;

while (count < 1000)="">

printf("%d "

count);

count++;

}

// 打印前1000个自然数的和

int sum = 0;

count = 1;

while (count <= 1000)="">

sum += count;

count++;

}

printf("\n前1000个自然数的和为: %d\n"

sum);

// 判断1000是否是素数

int isPrime = 1;

for (int i = 2; i <= 1000="" 2;="" i++)="">

if (1000 % i == 0) {

isPrime = 0;

break;

}

}

if (isPrime) {

printf("1000是素数\n");

} else {

printf("1000不是素数\n");

}

return 0;

}

Copyright © 悉地网 2018-2024.All right reserved.Powered by XIDICMS 备案号:苏ICP备18070416号-1