diff --git a/Code/output/sunhuan3 b/Code/output/sunhuan3 new file mode 100644 index 0000000..31b432b Binary files /dev/null and b/Code/output/sunhuan3 differ diff --git a/Code/output/test b/Code/output/test new file mode 100644 index 0000000..59e21bb Binary files /dev/null and b/Code/output/test differ diff --git a/Code/output/xunhuan1 b/Code/output/xunhuan1 index ea57106..96fc503 100644 Binary files a/Code/output/xunhuan1 and b/Code/output/xunhuan1 differ diff --git a/Code/output/xunhuan3 b/Code/output/xunhuan3 new file mode 100644 index 0000000..fcd7645 Binary files /dev/null and b/Code/output/xunhuan3 differ diff --git a/Code/output/xunhuan4 b/Code/output/xunhuan4 new file mode 100644 index 0000000..428ae19 Binary files /dev/null and b/Code/output/xunhuan4 differ diff --git a/Code/test.c b/Code/test.c new file mode 100644 index 0000000..aa7b17f --- /dev/null +++ b/Code/test.c @@ -0,0 +1,10 @@ +#include + +int main() +{ + + + + + return 0; +} \ No newline at end of file diff --git a/Code/xunhuan1.c b/Code/xunhuan1.c index c6251d9..c00ccde 100644 --- a/Code/xunhuan1.c +++ b/Code/xunhuan1.c @@ -2,11 +2,12 @@ int main() { - int x = 0,i = 0; - for(i = 1; i <= 100; i++) + int sum = 0,i = 1; + while(i <= 100) { - x += i; + sum += i; + i++; } - printf("%d\n", x); + printf("%d\n", sum); return 0; } \ No newline at end of file diff --git a/Code/xunhuan2.c b/Code/xunhuan2.c index c6e4b7e..a8d14c2 100644 --- a/Code/xunhuan2.c +++ b/Code/xunhuan2.c @@ -19,5 +19,19 @@ int main() } } + /* + while(1) + { + printf("请输入两个整数:\n"); + scanf("%d %d", &x , &y); + if(x == y) + { + printf("%d = %d\nexit\n",x,y); + break; + } + x > y ? printf("%d更大\n", x) : printf("%d更大\n", y); + + }*/ + return 0; } \ No newline at end of file diff --git a/Code/xunhuan3.c b/Code/xunhuan3.c new file mode 100644 index 0000000..bfc0709 --- /dev/null +++ b/Code/xunhuan3.c @@ -0,0 +1,27 @@ +#include + +int main() +{ + int n,i,j; + + for(j=0;j<5;j++) + { + printf("请输入第%d个数:\n",j+1); + + scanf("%d",&n); + + if(n<2) + { + printf("%d不是素数\n",n); + continue; + } + for(i=2;i + +int main() +{ + int n; //菱形的一半高度 + int i, j; + printf("请输入菱形的高度:"); + scanf("%d", &n); + //上半 + for (i = 1; i <= n; i++) + { + for (j = i; j < n; j++) + { + printf(" "); + } + for (j = 1; j <= (2 * i - 1); j++) + { + printf("*"); + } + printf("\n"); + } + + //下半 + for (i = n - 1; i >= 1; i--) + { + for (j = n; j > i; j--) + { + printf(" "); + } + for (j = 1; j <= (2 * i - 1); j++) + { + printf("*"); + } + printf("\n"); + } + + return 0; +} \ No newline at end of file