上一页 1 ··· 9 10 11 12 13
摘要: #include<stdio.h> #include<math.h> #define N 100 void StrVow(char str1[],char str2[]); int main(void){ char str1[N],str2[N]; printf("input first strin 阅读全文
posted @ 2024-05-11 15:32 zhongta 阅读(10) 评论(0) 推荐(0)
摘要: #include <stdio.h> #include <stdlib.h> #include <time.h> #define N 15 int main() { int a[N]={1,3,5,7,9,11,13,15,17,19,21,23,25,27,29}; int flag=1,sign 阅读全文
posted @ 2024-04-30 15:22 zhongta 阅读(26) 评论(0) 推荐(0)
摘要: 1.将1放在第一行中间一列 2.从2直到N*N为止,每一个数存放的行比前一个数的行数减1,列数加1。 3.如果上一数的行数为1,则下一数的行数为N。 4.如果上一数的列数为 N,下一个数列数为1,行数减1。 5.如果已经有数,把这一个数放在有数的正下方。(行数加1列数不变) #include<std 阅读全文
posted @ 2024-04-28 15:58 zhongta 阅读(20) 评论(0) 推荐(0)
摘要: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1。。。 #include<stdio.h> #define N 10 int main(void){ int a[N][N]; for(int i=0;i<N;i++){ a[i][0]=1;//first column is 1 a[i][ 阅读全文
posted @ 2024-04-28 15:10 zhongta 阅读(16) 评论(0) 推荐(0)
摘要: 1.先将1挖掉 2.用2除它以后的各个数,把能被2整除的数挖掉 3.依次处理3,4,5,6 sqrt(n)的数 4.挖掉的数设为0,不为0的数就是素数。(用数组存储) #include<stdio.h> #include<math.h> int main(void){ int number[1000 阅读全文
posted @ 2024-04-26 11:09 zhongta 阅读(94) 评论(0) 推荐(0)
摘要: #include<stdio.h> #include<math.h> double func(double x); int main(void){ double x0; double x1=-10; double x2=10; double fx1,fx2,fx0; fx1=func(x1); fx 阅读全文
posted @ 2024-04-25 11:47 zhongta 阅读(32) 评论(0) 推荐(0)
摘要: 公式 x2=0.5*(x1+a/x1); #include<stdio.h> #include<math.h> int main(void){ double x1,x2; double a=0; printf("input a number:"); scanf("%lf",&a); x2=a/2; 阅读全文
posted @ 2024-04-24 11:26 zhongta 阅读(34) 评论(0) 推荐(0)
摘要: 一个数恰好等于它的因子之和,这个数就称作完数。例如:6=1+2+3;编程序找出1000之内的完数。 include<stdio.h> void Factor(int num); int main(void){ for(int i=1;i<=1000;i++){ Factor(i); } } void 阅读全文
posted @ 2024-04-23 17:11 zhongta 阅读(36) 评论(0) 推荐(0)
摘要: int main(void){ int a=0,n=0; printf("input a and n:"); scanf("%d %d",&a,&n); long sum=0; int temp=a; int j=n; for(int i=1;i<=n;i++){ for(j=i;j>1;j--){ 阅读全文
posted @ 2024-04-23 11:16 zhongta 阅读(9) 评论(0) 推荐(0)
摘要: 1.最大公约数辗转相除法 int t; while(b!=0){ t=a%b; a=b; b=t; } printf("the gcd is %d\n",a); 2.最小公倍数 最小公倍数乘以最大公约数等于两数乘积,所以最小公倍数等于两数乘积除以最大公约数。 #include<stdio.h> #i 阅读全文
posted @ 2024-04-23 10:58 zhongta 阅读(37) 评论(0) 推荐(0)
上一页 1 ··· 9 10 11 12 13