From bbedce7b34705ba243f3dd9e13d372fef37c4d00 Mon Sep 17 00:00:00 2001 From: smallkun <smallerkun@foxmail.com> Date: Thu, 6 Mar 2025 19:58:58 +0800 Subject: [PATCH] 2025-03-06 --- .../C语言/C语言(四)/combine_c_files.sh | 0 .../C语言/C语言(四)/combined.md | 578 ++++++++++++++++++ 2 files changed, 578 insertions(+) mode change 100644 => 100755 2207/天天乐学答案/C语言/C语言(四)/combine_c_files.sh create mode 100644 2207/天天乐学答案/C语言/C语言(四)/combined.md diff --git a/2207/天天乐学答案/C语言/C语言(四)/combine_c_files.sh b/2207/天天乐学答案/C语言/C语言(四)/combine_c_files.sh old mode 100644 new mode 100755 diff --git a/2207/天天乐学答案/C语言/C语言(四)/combined.md b/2207/天天乐学答案/C语言/C语言(四)/combined.md new file mode 100644 index 0000000..0efb220 --- /dev/null +++ b/2207/天天乐学答案/C语言/C语言(四)/combined.md @@ -0,0 +1,578 @@ +### C����-1 +```c +/*------------------------------------------------------- +�������������߳����ж��ܷ������Σ����ܹ������������������������������ʾ�� +������ʽ���� +һ�������Σ��߳��ֱ�Ϊa��b��c�����S����һ�¹�ʽ��� +S=��p(p-a)(p-b)(p-c) +��ʽ��pΪ���ܳ����ܳ���һ�룩��P=(a+b+c)/2 +-------------------------------------------------------*/ + +#include <stdio.h> +#include <math.h> +/**********Program**********/ +double S(int a, int b, int c){ + return (a+b+c)/2; +} + +double AREA(double t, int a, int b, int c){ + return sqrt(t*(t-a)*(t-b)*(t-c)); +} + +/********** End **********/ +main() +{ + int a,b,c; + double t,area; + printf("��������������������ʾ�����ε������߳���"); + scanf("%d%d%d",&a,&b,&c); + if(a+b>c&&a+c>b&&b+c>a) + { + t=S(a,b,c); + area=AREA(t,a,b,c); + printf("�����ε�����ǣ�%f\n",area); + } + else + printf("���ܹ���������\n"); +} +``` + +### C����-2 +```c +/*------------------------------------------------------- +��һ��100Ԫ��Ʊ���ɵ�ֵ��10Ԫ��5Ԫ��2Ԫ��1Ԫ��С����ÿ�λ���40��С����Ҫ��ÿһ��С����Ҫ�У����������п��ܵĻ�������������������������ϡ�(ע��ʹ��forѭ���� +����� +10Ԫ��Ʊ��1�ţ�5Ԫ��Ʊ��5�ţ�2Ԫ��Ʊ��31�ţ�1Ԫ��Ʊ��3�� +10Ԫ��Ʊ��1�ţ�5Ԫ��Ʊ��6�ţ�2Ԫ��Ʊ��27�ţ�1Ԫ��Ʊ��6�� +10Ԫ��Ʊ��1�ţ�5Ԫ��Ʊ��7�ţ�2Ԫ��Ʊ��23�ţ�1Ԫ��Ʊ��9�� + �� + �� + �� + +�ܹ���34�ֻ��� +-------------------------------------------------------*/ +#include <stdio.h> +main() +{ + int a,b,c,d,s; + s=0; +/**********Program**********/ + for(a=1;a<10;a++){ + for(b=1;b<20;b++){ + for(c=1;c<50;c++){ + for(d=1;d<100;d++){ + if(a*10+b*5+c*2+d == 100 && a+b+c+d==40){ + s++; +/********** End **********/ + printf("10Ԫ��Ʊ��%d�ţ�5Ԫ��Ʊ��%d�ţ�2Ԫ��Ʊ��%d�ţ�1Ԫ��Ʊ��%d��\n",a,b,c,d); + } + } + } + } + } + printf("\n�ܹ���%d�ֻ���\n",s); +} + +``` + +### C����-3 +```c +/*------------------------------------------------------- +��̽�һ���������ֽ����������ע��ʹ��whileѭ���� +���磺 + ���� 90 + ��� 90=2*3*3*5 +-------------------------------------------------------*/ +#include <stdio.h> +main() +{ + int n,i; + printf("������һ����������"); + scanf("%d",&n); + printf("%d=",n); + i=2; +/**********Program**********/ + while(n > i){ + if(n%i==0){ + printf("%d*", i); + n/=i; + }else{ + i++; + } + } + +/********** End **********/ + printf("%d\n",n); +} +``` + +### C����-4 +```c +/*------------------------------------------------------- +���ŵ�������Ŵ�1500��ʿ�����̣�ս��������ˣ�վ3��һ�ţ����2�ˣ�վ5��һ�ţ����4�ˣ�վ7��һ�ţ����6�ˡ���̼��㻹�ж���ʿ���� (ע��ʹ��forѭ���� +-------------------------------------------------------*/ +#include <stdio.h> +main() +{ + int i; +/**********Program**********/ + for(i=1000;i<1100;i++){ + if(i%3==2 && i%5==4 && i%7==6) + +/********** End **********/ + printf("����%d��ʿ��\n",i); + } +} +``` + +### C����-5 +```c +/*------------------------------------------------------- +�����ٵ�����һ��ƥ������һ�ٵ�����������3����������2������ֻС����1����ÿƥ����Ҫ�Ի�����̼��������dm)������(zm)��С��(xm)���ж���ƥ�� ��ע��ʹ��forѭ���� +����� +������2ƥ��������30ƥ,С����68ƥ +������5ƥ��������25ƥ,С����70ƥ +������8ƥ��������20ƥ,С����72ƥ +������11ƥ��������15ƥ,С����74ƥ +������14ƥ��������10ƥ,С����76ƥ +������17ƥ��������5ƥ,С����78ƥ +-------------------------------------------------------*/ +#include <stdio.h> +void main() { + int dm,zm,xm; +/**********Program**********/ + for(dm=1;dm<66;dm++){ + for(zm=1;zm<100;zm++){ + for(xm=2;xm<200;xm+=2){ + if(dm*3+zm*2+xm/2 == 100 && dm+zm+xm==100) + +/********** End **********/ + printf("������%dƥ��������%dƥ,С����%dƥ\n",dm,zm,xm); + } + } + } +} +``` + +### C����-6 +```c +/*------------------------------------------------------- +����ͬ�����������㾭���м��أ�����������ͬ����������ʮ��ͷ�����о�ʮ���㣬�����ø����Σ�������̼��㼦�����Ӹ��ж���ֻ����ע��ʹ��forѭ���� +����� +����23ֻ,����12ֻ +-------------------------------------------------------*/ +#include <stdio.h> +main() +{ + int j,t; +/**********Program**********/ + for(j=1;j<35;j++){ + for(t=1;t<35;t++){ + if(j*2+t*4==94 && j+t == 35) + +/********** End **********/ + printf("����%dֻ,����%dֻ\n",j,t); + } + } +} +``` + +### C����-7 +```c +/*------------------------------------------------------- +������1000���ڵ���������ν������ָһ�������������ӣ�����1���������䱾����֮�͵��������������������28=1+2+4+7+14�� +-------------------------------------------------------*/ +#include <stdio.h> +main() +{ + int i,j,s; + for(i=2;i<=1000;i++) + { + s=0; +/**********Program**********/ + for(j=1;j<i;j++){ + if(i%j==0){ + s+=j; + } + } + +/********** End **********/ + if(s==i) + printf("%d\n",i); + } + +} + +``` + +### C����-8 +```c +/*------------------------------------------------------- +����������ܱ�3���ܱ�5���ܱ�7��������λ���������ÿ������ռ5�ַ����ȣ�5��һ�У��� +-------------------------------------------------------*/ +#include <stdio.h> +main() +{ + int i,k; + k=0; + for(i=100;i<=999;i++) + { +/**********Program**********/ + if(i%3 ==0 && i%5==0 && i%7==0){ + + + + +/********** End **********/ + printf("%5d",i); + k++; + if(k%5==0) + printf("\n"); + } + } +} +``` + +### C����-9 +```c +/*------------------------------------------------------- +����һ���������ж��Ƿ�Ϊ����������ν�������������ҶԳƵ����� +��ע��ʹ��whileѭ���� +-------------------------------------------------------*/ +#include <stdio.h> +main() +{ + int n,t,s; + s=0; + scanf("%d",&n); + t=n; +/**********Program**********/ + while(n){ + s*=10; + s+=n%10; + n/=10; + } + + + + +/********** End **********/ + if( t==s ) + printf("yes\n"); + else + printf("no\n"); +} + +``` + +### C����-10 +```c +/*------------------------------------------------------- +��Ǯ��ټ������㾭��һ���м��� +������һֵǮ�壬��ĸһֵǮ����������ֵǮһ����Ǯ��ټ����ʼ��̡���ĸ�����������Σ��� +Ҫ��ÿһ�ּ���Ҫ�У�������������gj����ĸ����mj����С����xj�����ж���ֻ�� +�����(ע��ʹ��forѭ���� + +������4ֻ��ĸ����18ֻ��С����78ֻ +������8ֻ��ĸ����11ֻ��С����81ֻ +������12ֻ��ĸ����4ֻ��С����84ֻ +-------------------------------------------------------*/ +#include <stdio.h> +void main() +{ + int gj,mj,xj; +/**********Program**********/ + for(gj=1;gj<20;gj++){ + for(mj=1;mj<34;mj++){ + for(xj=3;xj<300;xj+=3){ + if(gj+mj+xj==100 && gj*5+mj*3+xj/3 == 100) + +/********** End **********/ + printf("������%dֻ��ĸ����%dֻ��С����%dֻ\n",gj,mj,xj); + } + } + } +} +``` + +### C����-11 +```c +/*------------------------------------------------------- +�������㾭����������һ�������⣺�������ﲻ֪������������֮ʣ����������֮ʣ����������֮ʣ�������X�Σ��� (ע��ʹ��whileѭ���� +-------------------------------------------------------*/ +#include <stdio.h> +main() +{ + int i; + i=1; +/**********Program**********/ + while(1){ + + + + if(i%3==2&&i%5==3&&i%7==2) +/********** End **********/ + { + printf("%d\n",i); + break; + } + i++; + } +} +``` + +### C����-12 +```c +/*------------------------------------------------------- +61.�������ܡ����ӳ��ң����ӵ�һ��ժ�����ɸ����ӣ� ����������һ�룬�������ֶ����һ�����ڶ����ֽ�ʣ�µ����ӳԵ�һ�룬�ֶ����һ�����Ժ�ÿ�춼�����ԡ�����ʮ��ʱ�� ����ֻ��һ�������ˡ�������һ��ժ�˶��ٸ����ӡ�(ע��ʹ��forѭ���� +-------------------------------------------------------*/ +#include <stdio.h> + void main() { + int i,t; + t=1; +/**********Program**********/ + for(i=0;i<9;i++){ + t=(t+1)*2; + } + +/********** End **********/ + printf("��һ�칲ժ��%dֻ��\n",t); + } +``` + +### C����-13 +```c +/*------------------------------------------------------- +��д������sum)������1+2+3+��+n�ĺͣ�n�ɼ������롣 +-------------------------------------------------------*/ +#include <stdio.h> +int sum(int n); +main() +{ + int n,s; + printf("������һ������n:"); + scanf("%d",&n); + s=sum(n); + printf("1+2+...+%d=%d\n",n,s); +} +/**********Program**********/ +int sum(int n){ + int s = 0, i; + for(i=1;i<=n;i++){ + s += i; + } + return s; +} + + + + +/********** End **********/ +``` + +### C����-14 +```c +/*------------------------------------------------------- +����á���ת����������������������Լ�������������ɼ������롣(ע��ʹ��whileѭ���� +-------------------------------------------------------*/ +#include <stdio.h> +main() +{ + int m,n,t; + printf("����������������"); + scanf("%d%d",&m,&n); + t=m%n; +/**********Program**********/ + while(t){ + m = n; + n = t; + t = m%n; + } +/********** End **********/ + printf("���Լ���ǣ�%d\n",n); +} +``` + +### C����-15 +```c +/*------------------------------------------------------- +һ������������100������ȫƽ����������268����һ����ȫƽ�����������������������������10000������ +����� +21 +261 +1581 +-------------------------------------------------------*/ +#include <stdio.h> +#include <math.h> +main() +{ + int i,j,k; + for(i=1;i<=10000;i++) + { +/**********Program**********/ + if(pow((int)sqrt(i+100), 2) == i+100 && pow((int)sqrt(i+268), 2) == i+268){ + + +/********** End **********/ + printf("%d\n",i); + } + } +}``` + +### C����-16 +```c +/*------------------------------------------------------- +����һ����������������������ӣ�1�����������⣩֮�͡�����6��������2��3�������5 +(ע��ʹ��forѭ���� +-------------------------------------------------------*/ +#include <stdio.h> +main() +{ + int n,i,s; + printf("������һ������n��"); + scanf("%d",&n); + s=0; +/**********Program**********/ + for(i=2;i<n;i++){ + if(n%i==0){ + s+=i; + } + } + +/********** End **********/ + printf("s=%d\n",s); + +} + + +``` + +### C����-17 +```c +/*------------------------------------------------------- +�����100���ڵ���������֮�ͣ��Լ�ż��֮�͡���ע��ʹ��forѭ���� +-------------------------------------------------------*/ +#include <stdio.h> +main() +{ + int i,odd,even; + odd=even=0; +/**********Program**********/ + for(i=1;i<=100;i++){ + if(i%2){ + odd+=i; + }else{ + even+=i; + } + } + +/********** End **********/ + printf("����֮��Ϊ��%d,ż��֮��Ϊ��%d\n",odd,even); +} +``` + +### C����-18 +```c +/*------------------------------------------------------- +���100-1000�������еĻ�������һ��10����(ע��ÿ����ռ5���ַ��� + 101 111 121 131 141 151 161 171 181 191 + 202 212 222 232 242 252 262 272 282 292 + 303 313 323 333 343 353 363 373 383 393 + 404 414 424 434 444 454 464 474 484 494 + 505 515 525 535 545 555 565 575 585 595 + 606 616 626 636 646 656 666 676 686 696 + 707 717 727 737 747 757 767 777 787 797 + 808 818 828 838 848 858 868 878 888 898 + 909 919 929 939 949 959 969 979 989 999 +-------------------------------------------------------*/ +#include <stdio.h> +main() +{ + int i,s,t,k; + k=0; +/**********Program**********/ + for(i=100;i<1000;i++){ + s = 0; + t = i; + while(t){ + s*=10; + s+=t%10; + t/=10; + } + if(s == i){ + printf("%5d", i); + k++; + if(k%10==0){ + printf("\n"); + } + } + } + + + + +/********** End **********/ +} +``` + +### C����-19 +```c +/*------------------------------------------------------- +�������1��2��3��4�ĸ����ֿ�����ɶ��ٸ����ظ����ֵ���λ�����������Щ��λ������ע��ʹ��forѭ���� +����� +1234 +1243 +1324 + �� + �� + �� +�������24�����ظ����ֵ���λ�� +-------------------------------------------------------*/ +#include <stdio.h> +main() +{ + int a,b,c,d,count; + count=0; +/**********Program**********/ + for(a=1;a<5;a++) + for(b=1;b<5;b++) + for(c=1;c<5;c++) + for(d=1;d<5;d++) + if(a!=b && a!=c && a!=d && b!=c && b!=d && c!=d){ + printf("%d%d%d%d\n", a, b, c, d); + count++; + } +/********** End **********/ + printf("�������%d�����ظ����ֵ���λ��\n",count); +} +``` + +### C����-20 +```c +/*------------------------------------------------------- +һС���100�����£�ÿ�ε���ԭ��һ��ߣ����10�����ʱ�����ľ��뼰��10�ε����ĸ߶ȡ� +��ע��ʹ��forѭ���� +-------------------------------------------------------*/ + +#include <stdio.h> +main() +{ + int i; + double h,s; + s=100; + h=50; +/**********Program**********/ + for(i=0;i<9;i++){ + s+=h*2; + h/=2; + } + + + + +/********** End **********/ + printf("��10�����ʱ�����ľ���Ϊ%f�ף���10�ε����ĸ߶�Ϊ%f��\n",s,h); +} + +``` +