1 #include
2 #include
3
4 int main()
5 {
6 int x;
7 int a[100][100];
8 printf("输入行数\n");
9 scanf("%d",&x);
10 for(int i = 0;i
1 #include
2 #include
3
4 int func(int n)
5 {
6 if(0 == n) return 0;
7 if(1 == n) return 1;
8 else
9 return func(n-2)+func(n-1);
10 }
11
12 int main()
13 {
14 int n;
15 scanf("%d",&n);
16 printf("%d\n",func(n));
17
18 return 0;
19 }
1 #include
2 #include
3
4 int func(int n)
5 {
6 if(1 == n) return 1;
7 return n * func(n-1);
8 }
9
10 int main()
11 {
12 int n;
13 scanf("%d",&n);
14 printf("%d\n",func(n));
15
16 return 0;
17 }
1 #include
2 #include
3
4 int main()
5 {
6 int x,y,z,j;
7 scanf("%d%d",&x,&y);
8 if(x>y)
9 {
10 z = x;
11 }else{
12 z = y;
13 }
14
15 for(int i = z;i>0;i--)
16 {
17 j = i;
18 if(0 == x%i && 0 == y%i)
19 {
20 break;
21 }
22 }
23 printf("最大公约数为:%d\n",j);
24 printf("最小公倍数为:%d\n",(x*y)/j);
25
26 return 0;
27 }
1 #include
2 #include
3
4 int main()
5 {
6 int i,j;
7 for(i = 101;i<=200;i++)
8 {
9 for(j = 2;j
1 #include
2 #include
3
4 int main()
5 {
6 int len,cout = 0;
7 char a[] = "ABCDEFGAa";
8 char b = 'a';
9 len = strlen(a);
10 for(int i = 0;i
例如:153是一个“水仙花数”,因为153=1的三次方+5的三次方+3的三次方。
1 #include
2 #include
3
4 int main()
5 {
6 int i,a,b,c,cout = 0;
7 printf("打印100-999水仙花个数\n");
8 for(i = 100;i<999;i++)
9 {
10 a = i/100;
11 b = i/10 %10;
12 c = i%10;
13 if(i == (a*a*a)+(b*b*b)+(c*c*c))
14 {
15 cout++;
16 printf("%d ",i);
17 }
18 }
19 printf("水仙花个数为:%d\n",cout);
20
21 return 0;
22 }
1 #include
2 #include
3
4 int main()
5 {
6 int i = 0,b = 0,c = 0,d = 0,e = 0;
7 char a[] = "ASsfDGG& adS A18";
8 while(a[i] != '\0')
9 {
10 if(a[i] >= '1' && a[i] <= '9')
11 {
12 b++;
13 }
14 else if(a[i] >= 'a' && a[i] <= 'z' || a[i] >= 'A' && a[i] <= 'Z')
15 {
16 c++;
17 }
18 else if(a[i] == ' ')
19 {
20 d++;
21 }
22 else
23 {
24 e++;
25 }
26 i++;
27 }
28 printf("数字的个数为:%d,字母的个数为:%d,空格的个数为:%d,其他符号的个数为:%d",b,c,d,e);
29
30 return 0;
31 }
1 #include
2 #include
3
4 int main()
5 {
6 int i,j,num;
7 printf("输出9*9乘法口诀\n");
8 for(i = 1;i<=9;i++)
9 {
10 for(j = 1;j<=i;j++)
11 {
12 num = i * j;
13 printf("%d * %d = %d ",i,j,num);
14 }
15 printf("\n");
16 }
17
18 return 0;
19 }
1 #include
2 #include
3
4 int main()
5 {
6 int i,j,k;
7 for(i = 1;i<=4;i++)
8 {
9 for(j = 0;j<4-i;j++)
10 {
11 printf(" ");
12 }
13 for(k = 0;k<(2*i)-1;k++)
14 {
15 printf("*");
16 }
17 printf("\n");
18 }
19
20 for(i = 1;i<=3;i++)
21 {
22 for(j = 0;j
1 #include
2 #include
3
4 int main()
5 {
6 int a[] = {1,2,3,4};
7 int i,j,k,cout = 0;
8 for(i = 0;i<4;i++)
9 {
10 for(j = 0;j<4;j++)
11 {
12 for(k = 0;k<4;k++)
13 {
14 if(i != j && j != k && i != k)
15 {
16 printf("%d%d%d ",a[i],a[j],a[k]);
17 cout++;
18 }
19 }
20 }
21 printf("\n");
22 }
23 printf("可以组成%d个互不相同且无重复数字的三位数\n",cout);
24 return 0;
25 }
1 #include
2
3 int main()
4 {
5 int a,n,s = 0,b;
6 printf("请输入相加个数n和加数a\n");
7 scanf("%d%d",&a,&n);
8 printf("s = %d ",a);
9 b = a;
10 for(int i = 0;i
https://blog.csdn.net/m0_55028858/article/details/125577635
1 #include
2
3 int main()
4 {
5 int s;
6 for(int i = 2;i<1000;i++)
7 {
8 s = 0;
9 for(int j = 1;j
https://blog.csdn.net/qq_45385706/article/details/110697089
1 #include
2
3 int main()
4 {
5 double s = 100,h = s/2,k = 0;
6 for(int i = 0;i<9;i++)
7 {
8 k = k + (2 * h);
9 h = h/2;
10 }
11 k = k + s;
12 printf("总共经过%lf米,第10次反弹的高度为%lf",k,h);
13
14 return 0;
15 }
1 #include
2
3 int main()
4 {
5 int y = 1;
6 for(int i = 0;i<9;i++)
7 {
8 y = (y + 1) * 2;
9 }
10 printf("第一天总共有%d颗桃子\n",y);
11
12 return 0;
13 }
1 #include
2
3 int main()
4 {
5 double x = 2,y = 1,s = 0,x1 = 0;
6 for(int i = 0;i<20;i++)
7 {
8 s = s + (x/y);
9 x1 = x;
10 x = x + y;
11 y = x1;
12 }
13 printf("前20项的和为%lf\n",s);
14
15 return 0;
16 }
https://blog.csdn.net/daonanya/article/details/123506362
1 #include
2
3 int main()
4 {
5 int a = 12321,b,c,d,e;
6 b = a/10000;
7 c = (a%10000)/1000;
8 d = (a%100)/10;
9 e = a%10;
10 if(b == e && c == d)
11 {
12 printf("是回文数\n");
13 }
14 else
15 {
16 printf("不是回文数\n");
17 }
18
19 return 0;
20 }
https://blog.csdn.net/azulgrana02/article/details/109644046
1 #include
2 #include
3 #include
4 using namespace std;
5
6 class node{
7 public:
8 vector twosun(vector& nums,int target)
9 {
10 unordered_map record;
11 for(int i = 0;i cur;
26 vector nums = {2,7,11,15};
27 cur = n.twosun(nums,9);
28 for (auto i : cur)
29 cout << i << endl;
30
31 return 0;
32 }
1 #include
2 #include
3 using namespace std;
4
5 class node{
6 public:
7 int reverse(int x){
8 int ans = 0;
9 while(x){
10 ans = ans*10 + x%10;
11 x /= 10;
12 }
13 return ans;
14 }
15 };
16
17 int main()
18 {
19 node n;
20 cout << n.reverse(-123) << endl;
21
22 return 0;
23 }
1 #include
2 #include
3 #include
4 using namespace std;
5
6 class node{
7 public:
8 vector> merge(vector>& cur){
9 vector> ans;
10 sort(cur.begin(),cur.end());
11 int strat = cur[0][0],end = cur[0][1];
12 for(int i = 1;iend){
14 ans.push_back({strat,end});
15 strat = cur[i][0];
16 end = cur[i][1];
17 }else{
18 end = max(end,cur[i][1]);
19 }
20 }
21 ans.push_back({strat,end});
22 return ans;
23 }
24 };
25
26 int main()
27 {
28 node n;
29 vector> top;
30 vector> tem;
31 tem.push_back({1,3});
32 tem.push_back({2,6});
33 tem.push_back({8,10});
34 tem.push_back({15,18});
35 top = n.merge(tem);
36 int x = top.size(),y = top[0].size();
37 for(int i = 0;i
1 #include
2 #include
3 #include
4 using namespace std;
5
6 class node{
7 public:
8 vector> insert(vector>& a,vector& b){
9 vector> ans;
10 int n = a.size(),i = 0;
11 while(i tur ={2,5};
32 vector> tem;
33 tem.push_back({1,3});
34 tem.push_back({6,9});
35 vector> top;
36 top = n.insert(tem,tur);
37 int x= top.size(),y = top[0].size();
38 for(int i = 0;i
1 #include
2 #include
3 using namespace std;
4
5 class node{
6 public:
7 vector piusone(vector& cur){
8 for(int i = cur.size()-1;i>=0;i++){
9 if(cur[i]<9){
10 cur[i]++;
11 break;
12 }else{
13 cur[i] = 0;
14 if(i==0){
15 cur.insert(cur.begin(),1);
16 }
17 }
18 }
19 return cur;
20 }
21 };
22
23 int main()
24 {
25 node n;
26 vector tem;
27 vector top = {1,2,3};
28 tem = n.piusone(top);
29 for(int i = 0;i