intprime(int p){int count =0;if(p==1)return0;for(int i =2; i <= p; i++){if(p % i ==0)count++;}if(count ==1)return1;elsereturn0;}intPrimeSum(int m,int n){int sum =0;for(int i =(m<=n?m:n); i <=(n>=m?n:m); i++){if(prime(i)==1)sum += i;}return sum;}
6-7 使用函数输出水仙花数
#include<math.h>intnarcissistic(int number){int count =0;int sum1 =0;int num = number;while(number){number /=10;count++;}int sum =0;number = num;while(number){sum1 = number %10;sum +=(int)(pow(sum1, count));number /=10;sum1 =0;}if(num == sum)return1;elsereturn0;}voidPrintN(int m,int n){for(int i =(m <= n ? m : n)+1; i <(n >= m ? n : m); i++){if(narcissistic(i)==1){printf("%d\n", i);}}}
二.编程题
7-1 寻找自守数
#include<stdio.h>intZISHOUnum(int p){int num =0, count =0;num = p * p;while(p !=0){if(p %10!= num %10)return0;p /=10;num /=10;}return1;}intmain(){int n =0, m =0;int count =0;scanf("%d %d",&n,&m);for(int i = n; i <= m; i++){if(ZISHOUnum(i)){count++;printf("%d\n", i);}}if(count ==0){printf("None\n");}return0;}
#include<bits/stdc.h>
using namespace std;
int main(){//beginint a 0, b 0, c 0, d 0, e 0;char f1, f2;char g[30];scanf("%d", &a); //输入整数并赋值给变量ascanf("%d", &b); //输入整数并赋值给变量bscanf("%d", &…
使用Promise ,当 layer.msg(查询成功) 这个方法执行结束后 ,下面代码才会执行 let thas this
async function showMessage() {await new Promise(resolve > layer.msg(查询成功, resolve));// 这里的代码将在 layer.msg 执行结束后执行thas.isGuaran…