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;}
思路:
1.树中的第一个值为根(数组的第一个值),小于根的值存放在左子树中,大于根的值存放在右子树中;
2.利用递归对左右子树 /*** Definition for a binary tree node.* struct TreeNode {* int val;*…
msvcp71.dll是Microsoft Visual C 2003运行库中的一个组件,它是Microsoft Visual C 2003编译的程序在运行时所需要的动态链接库文件。它包含了许多C标准库函数的实现,如字符串处理、数学计算等。当程序运行时,如果缺少这个文件,就…