Skip to content

Commit 1d2a1b5

Browse files
把一直以来写的玩意放上来了
1 parent 09a9e8d commit 1d2a1b5

File tree

15 files changed

+240
-0
lines changed

15 files changed

+240
-0
lines changed

C-exp/1-6b2.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <stdio.h>
2+
3+
int main() {
4+
int a, b, max;
5+
6+
printf("请输入A,B的值(整数!):\n");
7+
scanf("%d,%d", &a, &b);
8+
9+
if (a > b) {
10+
max = a;
11+
} else {
12+
max = b;
13+
}
14+
15+
printf("较大的值是:%d\n", max);
16+
17+
return 0; // 添加return语句,使程序正常退出
18+
}

C-exp/1-6b3.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <stdio.h>
2+
#include <math.h>
3+
int main()
4+
{
5+
float r,h,V;
6+
printf("请输入圆柱体的半径和高:");
7+
scanf("%f %f",&r,&h);
8+
V=M_PI*r*r*h;
9+
printf("圆柱体的体积为:%f",V);
10+
return 0;
11+
}
12+
// 你好啊
13+
// 这是一个注释

C-exp/2-1.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include <stdio.h>
2+
3+
int main() {
4+
// 声明变量用于存储输入的字符
5+
char ch1, ch2;
6+
7+
// 提示用户输入第一个字符并按下回车键
8+
printf("请输入第一个字符: ");
9+
10+
// 读取一个字符,并将其赋值给ch1
11+
ch1 = getchar();
12+
if (ch1 == '\n') { // 判断是否直接按下了回车键,如果是则提示重新输入
13+
printf("请不要直接按下回车键,请输入一个字符: ");
14+
ch1 = getchar();
15+
}
16+
17+
// 提示用户输入第二个字符并按下回车键
18+
printf("请输入第二个字符: ");
19+
20+
// 读取另一个字符,并将其赋值给ch2
21+
ch2 = getchar();
22+
if (ch2 == '\n') { // 判断是否直接按下了回车键,如果是则提示重新输入
23+
printf("请不要直接按下回车键,请输入一个字符: ");
24+
ch2 = getchar();
25+
}
26+
27+
// 输出两个字符
28+
putchar(ch1);
29+
putchar(ch2);
30+
31+
return 0;
32+
}

C-exp/2-2.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <stdio.h>
2+
3+
int main(){
4+
int a;
5+
float b;
6+
double c;
7+
8+
printf("请输入1个10进制整数、1个单精度浮点、1个双精度浮点数:");
9+
scanf("%d %f %lf",&a,&b,&c);
10+
printf("你输入的10进f制整数是: %d\n", a);
11+
printf("你输入的单精度浮点数是: %.1f\n", b);
12+
printf("你输入的双精度浮点数是: %.2lf\n", c);
13+
return 0;
14+
}

C-exp/2-3.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <stdio.h>
2+
3+
int main(){
4+
int a;
5+
printf("请输入一个十进制整数:");
6+
scanf("%d",&a);
7+
printf("八进制为:%o;十进制为:%d,十六进制为:%x",a,a,a);
8+
return 0;
9+
}

C-exp/4.3-2.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <stdio.h>
2+
#include <ctype.h>
3+
int main(){
4+
char a,b,x; int i;
5+
while (! isupper(getchar()));
6+
for(a='A';a<=x;a++){
7+
for(b='A';b<'A'+x-a;b++){
8+
putchar(' ');
9+
}
10+
for(i=1;i<=2*(a-'A')+1;i++)
11+
{
12+
putchar(a);
13+
}
14+
putchar('\n');
15+
}
16+
return 0;
17+
}
18+

C-exp/4.4-1.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <stdio.h>
2+
void main(){
3+
int m,n,jc=1;
4+
scanf("%d",&m);
5+
for(n=2;jc<=m;n++){
6+
jc=jc*n;
7+
}
8+
printf("n=%d\n",n-2);
9+
}
10+
11+

C-exp/4.4-2.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include<stdio.h>
2+
int main() {
3+
int a, b, c, i;
4+
5+
for (a = 6; a <= 10000; a++) {
6+
b = 1;
7+
//计算 a 的真因数之和
8+
for (i = 2; i <= a / 2; i++) {
9+
if (a % i == 0) {
10+
b += i;
11+
}
12+
}
13+
14+
c = 1;
15+
//计算 b 的真因数之和
16+
for (i = 2; i <= b / 2; i++) {
17+
if (b % i == 0) {
18+
c += i;
19+
}
20+
}
21+
22+
//检查是否是亲密数对,并且 a 和 b 不相等
23+
if (c == a && a != b) {
24+
printf("%d %d\n", a, b);
25+
}
26+
}
27+
28+
return 0;
29+
}

C-exp/4.5-1.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include<stdio.h>
2+
#include<math.h>
3+
int main(){
4+
float x,y=0.0;
5+
scanf("%f",&x);
6+
if(0<=x&&x<=1){
7+
y= x+ cos(x);
8+
}else{
9+
y= x+ sin(x);
10+
}
11+
printf("%f",y);
12+
13+
return 0;
14+
}

C-exp/5.2-3.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <stdio.h>
2+
int f1(int,int),f11(int);
3+
void f2(int);
4+
void main(){
5+
int i,j;
6+
for(i=0;i<5;i++){
7+
f2((5-i)*3);for(j=0;j<=i;j++) printf("%3d",f1(i,j));
8+
putchar('\n');
9+
}
10+
}
11+
12+
int f1(int m, int n){
13+
return f11(m)/f11(n)/f11(m-n);
14+
}
15+
16+
int f11(int k){
17+
if(k<=1) return 1;
18+
return k*f11(k-1);
19+
}
20+
21+
void f2(int n){
22+
for(int i=1;i<=n;i++) putchar(' ');
23+
}

C-exp/5.3-2.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <stdio.h>
2+
3+
void f10_2(int n) {
4+
if (n == 0) { // 基本情况:当 n 为 0 时停止递归并返回
5+
return;
6+
} else {
7+
f10_2(n / 2); // 递归调用,处理 n 的整数部分
8+
printf("%d", n % 2); // 输出二进制位
9+
}
10+
}
11+
12+
int main() {
13+
int n = 11; // 示例输入
14+
f10_2(n);
15+
return 0;
16+
}

C-exp/5.3-3.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <stdio.h>
2+
#define S x=y=z
3+
#define P3(x,y,z) printf("x=%d\ty=%d\tz=%d\n",x,y,z)
4+
int mian(){
5+
int x,y,z;
6+
S=1; ++x||++y||++z; P3(x,y,z);
7+
S=1; ++x&&++y||++z; P3(x,y,z);
8+
S=-1;++x||++y&&++z; P3(x,y,z);
9+
S=-1;++x&&++y&&++z; P3(x,y,z);
10+
return 0;
11+
}

C-exp/trackbug.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include<stdio.h>
2+
#include<math.h>
3+
int main()
4+
5+
{
6+
float z;
7+
double x,y;
8+
9+
printf("请输入x和y的值:");
10+
scanf("%lf%lf",&x,&y);
11+
if(x>=0){
12+
if(y>=0){
13+
z=x*x+y*y;
14+
}else{
15+
z=x+y;
16+
}
17+
} else if(y>=0){
18+
z=x-y;
19+
}else{
20+
z=x*x-y*y;
21+
}
22+
23+
printf("函数的值为:%0.1lf",z);
24+
return 0;
25+
}
26+

C-exp/untitled1.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include<stdio.h>
2+
int main(){
3+
printf("\\\\\\\\n\\\ \0\\");
4+
return 0;
5+
}

stdserve-Back_end/Back-end

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 9a21d260a8fee595cd4f3f1229f2b1a9be48be4f

0 commit comments

Comments
 (0)