//输入一个字符,判断该数是否为素数,若是,输出该数,若否,输出大于该整数的第一个素数。例如,输入:14 输出:17(因为17是大于14的第一个素数) 代码: #include <cstdio>bool is_suNum(int m) {for (int i = 2; i < m; ++i) {if (m % i == 0)return false;//不是素数}return true;}
#include <stdio.h> #include <conio.h> int main(){ int a[7]={1,2,3,4,5,6,7}; int i,num,n,low,high,mid; printf("数组为:\n"); for(i=0;i<7;i++) printf("%3d",a[i]); printf("\n请输入
int factorsum( int number ){int sum=0;int i;for(i=1;i<number;i++){if(number%i==0){sum+=i;}}if(sum==i){return sum;}}void PrintPN( int m, int n ){int flag=0,sum=0;for(int i=m;i<=n;i++){if(factorsum(
方法1.for循环 #define _CRT_SECURE_NO_WARNINGS 1#include <stdio.h>#include <stdlib.h>int main(){int i = 0;int count = 0;printf("水仙花数有:\n");for (i = 100; i < 1000; i++){int bai = i / 100;int shi = i /