-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
09a9e8d
commit 1d2a1b5
Showing
15 changed files
with
240 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <stdio.h> | ||
|
||
int main() { | ||
int a, b, max; | ||
|
||
printf("请输入A,B的值(整数!):\n"); | ||
scanf("%d,%d", &a, &b); | ||
|
||
if (a > b) { | ||
max = a; | ||
} else { | ||
max = b; | ||
} | ||
|
||
printf("较大的值是:%d\n", max); | ||
|
||
return 0; // 添加return语句,使程序正常退出 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <stdio.h> | ||
#include <math.h> | ||
int main() | ||
{ | ||
float r,h,V; | ||
printf("请输入圆柱体的半径和高:"); | ||
scanf("%f %f",&r,&h); | ||
V=M_PI*r*r*h; | ||
printf("圆柱体的体积为:%f",V); | ||
return 0; | ||
} | ||
// 你好啊 | ||
// 这是一个注释 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <stdio.h> | ||
|
||
int main() { | ||
// 声明变量用于存储输入的字符 | ||
char ch1, ch2; | ||
|
||
// 提示用户输入第一个字符并按下回车键 | ||
printf("请输入第一个字符: "); | ||
|
||
// 读取一个字符,并将其赋值给ch1 | ||
ch1 = getchar(); | ||
if (ch1 == '\n') { // 判断是否直接按下了回车键,如果是则提示重新输入 | ||
printf("请不要直接按下回车键,请输入一个字符: "); | ||
ch1 = getchar(); | ||
} | ||
|
||
// 提示用户输入第二个字符并按下回车键 | ||
printf("请输入第二个字符: "); | ||
|
||
// 读取另一个字符,并将其赋值给ch2 | ||
ch2 = getchar(); | ||
if (ch2 == '\n') { // 判断是否直接按下了回车键,如果是则提示重新输入 | ||
printf("请不要直接按下回车键,请输入一个字符: "); | ||
ch2 = getchar(); | ||
} | ||
|
||
// 输出两个字符 | ||
putchar(ch1); | ||
putchar(ch2); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <stdio.h> | ||
|
||
int main(){ | ||
int a; | ||
float b; | ||
double c; | ||
|
||
printf("请输入1个10进制整数、1个单精度浮点、1个双精度浮点数:"); | ||
scanf("%d %f %lf",&a,&b,&c); | ||
printf("你输入的10进f制整数是: %d\n", a); | ||
printf("你输入的单精度浮点数是: %.1f\n", b); | ||
printf("你输入的双精度浮点数是: %.2lf\n", c); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include <stdio.h> | ||
|
||
int main(){ | ||
int a; | ||
printf("请输入一个十进制整数:"); | ||
scanf("%d",&a); | ||
printf("八进制为:%o;十进制为:%d,十六进制为:%x",a,a,a); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <stdio.h> | ||
#include <ctype.h> | ||
int main(){ | ||
char a,b,x; int i; | ||
while (! isupper(getchar())); | ||
for(a='A';a<=x;a++){ | ||
for(b='A';b<'A'+x-a;b++){ | ||
putchar(' '); | ||
} | ||
for(i=1;i<=2*(a-'A')+1;i++) | ||
{ | ||
putchar(a); | ||
} | ||
putchar('\n'); | ||
} | ||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include <stdio.h> | ||
void main(){ | ||
int m,n,jc=1; | ||
scanf("%d",&m); | ||
for(n=2;jc<=m;n++){ | ||
jc=jc*n; | ||
} | ||
printf("n=%d\n",n-2); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include<stdio.h> | ||
int main() { | ||
int a, b, c, i; | ||
|
||
for (a = 6; a <= 10000; a++) { | ||
b = 1; | ||
//计算 a 的真因数之和 | ||
for (i = 2; i <= a / 2; i++) { | ||
if (a % i == 0) { | ||
b += i; | ||
} | ||
} | ||
|
||
c = 1; | ||
//计算 b 的真因数之和 | ||
for (i = 2; i <= b / 2; i++) { | ||
if (b % i == 0) { | ||
c += i; | ||
} | ||
} | ||
|
||
//检查是否是亲密数对,并且 a 和 b 不相等 | ||
if (c == a && a != b) { | ||
printf("%d %d\n", a, b); | ||
} | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include<stdio.h> | ||
#include<math.h> | ||
int main(){ | ||
float x,y=0.0; | ||
scanf("%f",&x); | ||
if(0<=x&&x<=1){ | ||
y= x+ cos(x); | ||
}else{ | ||
y= x+ sin(x); | ||
} | ||
printf("%f",y); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <stdio.h> | ||
int f1(int,int),f11(int); | ||
void f2(int); | ||
void main(){ | ||
int i,j; | ||
for(i=0;i<5;i++){ | ||
f2((5-i)*3);for(j=0;j<=i;j++) printf("%3d",f1(i,j)); | ||
putchar('\n'); | ||
} | ||
} | ||
|
||
int f1(int m, int n){ | ||
return f11(m)/f11(n)/f11(m-n); | ||
} | ||
|
||
int f11(int k){ | ||
if(k<=1) return 1; | ||
return k*f11(k-1); | ||
} | ||
|
||
void f2(int n){ | ||
for(int i=1;i<=n;i++) putchar(' '); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <stdio.h> | ||
|
||
void f10_2(int n) { | ||
if (n == 0) { // 基本情况:当 n 为 0 时停止递归并返回 | ||
return; | ||
} else { | ||
f10_2(n / 2); // 递归调用,处理 n 的整数部分 | ||
printf("%d", n % 2); // 输出二进制位 | ||
} | ||
} | ||
|
||
int main() { | ||
int n = 11; // 示例输入 | ||
f10_2(n); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include <stdio.h> | ||
#define S x=y=z | ||
#define P3(x,y,z) printf("x=%d\ty=%d\tz=%d\n",x,y,z) | ||
int mian(){ | ||
int x,y,z; | ||
S=1; ++x||++y||++z; P3(x,y,z); | ||
S=1; ++x&&++y||++z; P3(x,y,z); | ||
S=-1;++x||++y&&++z; P3(x,y,z); | ||
S=-1;++x&&++y&&++z; P3(x,y,z); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include<stdio.h> | ||
#include<math.h> | ||
int main() | ||
|
||
{ | ||
float z; | ||
double x,y; | ||
|
||
printf("请输入x和y的值:"); | ||
scanf("%lf%lf",&x,&y); | ||
if(x>=0){ | ||
if(y>=0){ | ||
z=x*x+y*y; | ||
}else{ | ||
z=x+y; | ||
} | ||
} else if(y>=0){ | ||
z=x-y; | ||
}else{ | ||
z=x*x-y*y; | ||
} | ||
|
||
printf("函数的值为:%0.1lf",z); | ||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include<stdio.h> | ||
int main(){ | ||
printf("\\\\\\\\n\\\ \0\\"); | ||
return 0; | ||
} |
Submodule Back-end
added at
9a21d2