Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

作业 #46

Open
wants to merge 82 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
2641546
C_level0_c0_chenshuwei
csw981001 Feb 24, 2017
283418f
Create c1_1
csw981001 Feb 24, 2017
c6b066c
Create c1_1
csw981001 Feb 24, 2017
a1f8b7a
Create c1_2
csw981001 Feb 24, 2017
8c20a43
Create c1_3
csw981001 Feb 24, 2017
e908cc7
Create c1_4
csw981001 Feb 24, 2017
8369693
Create c1_5
csw981001 Feb 24, 2017
3fd184c
Create c1_6
csw981001 Feb 24, 2017
6642610
Create c1_6
csw981001 Feb 24, 2017
ca6f204
Create c2_1
csw981001 Feb 24, 2017
5bc0147
Create c2_2
csw981001 Feb 24, 2017
b57b0a7
Create c2_1.1.1
csw981001 Feb 25, 2017
529e150
Create c2_1.1.2
csw981001 Feb 25, 2017
c5befae
Create c2_1.1.3
csw981001 Feb 25, 2017
dc8d869
Create c2_1.1.4
csw981001 Feb 25, 2017
fff07fa
Create c2_1.1.4
csw981001 Feb 25, 2017
99bf1fa
Create level0_c3_1.1.6
csw981001 Mar 2, 2017
f2e36d8
Create level0_c3_1.1.5.c
csw981001 Mar 2, 2017
206bf1c
Create level0_c3_1.1.7.c
csw981001 Mar 2, 2017
e4bf745
Rename level0_c3_1.1.5.c to level0_c2_1.1.5.c
csw981001 Mar 2, 2017
520e187
Rename level0_c3_1.1.6 to level0_c2_1.1.6
csw981001 Mar 2, 2017
7f9fd9f
Rename level0_c3_1.1.7.c to level0_c2_1.1.7.c
csw981001 Mar 2, 2017
8f1f954
Rename level0_c2_1.1.6 to level0_c2_1.1.6.c
csw981001 Mar 2, 2017
de01525
Create c3_1.c
csw981001 Mar 2, 2017
cf6145f
Create level0_c3_2.c
csw981001 Mar 2, 2017
e49cc7b
Rename c3_1.c to level0_c3_1.c
csw981001 Mar 2, 2017
82a888b
Create level0_c3_3.c
csw981001 Mar 2, 2017
66d58f9
Create level0_c3_4.c
csw981001 Mar 2, 2017
8d0340a
Create level0_c3_6.c
csw981001 Mar 2, 2017
285311b
Create level0_c3_5.c
csw981001 Mar 3, 2017
e76548e
Create level0_c3_5.changed.c
csw981001 Mar 3, 2017
b796fed
Delete level0_c3_5.changed.c
csw981001 Mar 3, 2017
45f6e6b
Create level0_c3_5.changed.c
csw981001 Mar 3, 2017
4e2390f
Create level0_c3_5_changed_changed.c
csw981001 Mar 3, 2017
0b6b717
Rename practices/c/level0/c0 to practices/ c/ level0/c0.c
csw981001 Mar 15, 2017
8cedf75
Rename practices/c/level0/c1_1 to practices/ c/ level0/c1_1.c
csw981001 Mar 15, 2017
f47626d
Rename practices/c/level0/c2_2 to practices/ c/ level0/c2_2.c
csw981001 Mar 15, 2017
2ae321b
Rename practices/c/level0/c1_2 to practices/ c/ level0/c1_2.c
csw981001 Mar 15, 2017
06581aa
Rename practices/c/level0/c1_3 to practices/ c/ level0/c1_3.c
csw981001 Mar 15, 2017
78a1c20
Rename c1_4 to c1_4.c
csw981001 Mar 15, 2017
10e51d0
Rename practices/c/level0/c1_5 to practices/ c/ level0/c1_5.c
csw981001 Mar 15, 2017
5fe6034
Rename practices/c/level0/c2_1.1.1 to practices/ c/ level0/c2_1.1.1.c
csw981001 Mar 15, 2017
5eddd99
Rename c2_1.1.4 to c2_1.1.4.c
csw981001 Mar 15, 2017
1ac744c
Update and rename c1_6. to c1_6.c
csw981001 Mar 15, 2017
9b98a0a
Rename practices/c/level0/c2_1 to practices/ c/ level0/c2_1.c
csw981001 Mar 15, 2017
9d9cf3e
Rename practices/c/level0/c2_1.1.2 to practices/ c/ level0/c2_1.1.2.c
csw981001 Mar 15, 2017
0fa484e
Rename practices/c/level0/c2_1.1.3 to practices/ c/ level0/c2_1.1.3.c
csw981001 Mar 15, 2017
117ef0d
Rename practices/ c/ level0/c1_6 to practices/ c/ level0/c1_6.c
csw981001 Mar 15, 2017
680ea73
Delete c1_1
csw981001 Mar 15, 2017
128dc1e
Create runningletter.c
csw981001 Mar 22, 2017
29d9cfc
Create isprime.c
csw981001 Mar 27, 2017
32bef3f
Create Diophantus.c
csw981001 Mar 27, 2017
ae978cf
Rename Diophantus.c to Diophants.c
csw981001 Mar 27, 2017
438c373
Create shuixian.c
csw981001 Mar 27, 2017
f6816bf
Create allprimes.c
csw981001 Mar 27, 2017
ac155ee
Create Goldbach.c
csw981001 Mar 27, 2017
74f0f07
Create hanoi.c
csw981001 Mar 27, 2017
8f23e0c
Update and rename practices/ c/ level1/ p08_hanoi/hanoi.c to practic…
csw981001 Mar 27, 2017
b55de5c
list
csw981001 May 1, 2017
1118318
Create jinxiaoxun
csw981001 May 1, 2017
2363369
Create pushbox
csw981001 May 1, 2017
345fbb3
Create maze
csw981001 May 1, 2017
4317b4d
Update and rename practices/ c/ level1/ p12_warehouse/jinxiaoxun to …
csw981001 May 1, 2017
531d251
Rename practices/ c/ level1/ p11_linkedList/list to practices/ c/ le…
csw981001 May 3, 2017
4afca50
Rename practices/ c/ level1/ p12_warehouse/jinxiaoxun to practices/ …
csw981001 May 3, 2017
6bf494b
Rename practices/ c/ level1/font-font- p10_pushBoxes /font /pushbox t…
csw981001 May 3, 2017
186e5a9
Rename practices/ c/ level1/ p09_maze/maze to practices/ c/ level1/ …
csw981001 May 3, 2017
dd935e9
Create queue.cpp
csw981001 May 3, 2017
7d17655
Update and rename practices/ cpp/ level1/ p01_Queue/queue.cpp to pra…
csw981001 May 7, 2017
3a66ab8
Create stack.cpp
csw981001 May 7, 2017
014d82c
Create safearray.cpp
csw981001 May 7, 2017
419211a
Create canvas.cpp
csw981001 May 8, 2017
fa1b608
Create CircleAndPoint.cpp
csw981001 May 8, 2017
db127fb
Create cppScoreManagement.cpp
csw981001 May 10, 2017
9df2425
Create fighter.cpp
csw981001 May 21, 2017
ff1c8b6
Update and rename practices/ cpp/ level1/ p11_Fighters/fighter.cpp to…
csw981001 May 21, 2017
cf36593
Create fighter
csw981001 May 30, 2017
195d663
Update and rename practices/ cpp/ level1/ p11_Fighters/fighter to pr…
csw981001 May 31, 2017
019eafb
Create fighter_another.cpp
csw981001 Jun 9, 2017
d7cb9bb
Update and rename practices/ cpp/ level1/ p11_Fighters/fighter_anothe…
csw981001 Jun 15, 2017
e3c4bcb
Update fighter_another.cpp
csw981001 Jun 17, 2017
4a73c4a
Create classes.h
csw981001 Jun 17, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions c2_1.1.4
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <stdio.h>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

文件名后缀应该是.c

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已经修改了 俸爷有空看看

void printf_X(int a);
void main()
{
int i, j;
for (i = 1; i <= 9; i++)
{
printf_X(i);
printf("\n");
}
}

void printf_X(int a)
{
int j;
for (j = 1; j <= a; j++)
{
printf("%dX%d=%d\t", a, j, a*j);
}
}
5 changes: 5 additions & 0 deletions practices/ c/ level0/c0.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <stdio.h>
void main()
{
printf("Hello,world!我是陈叔炜");
}
21 changes: 21 additions & 0 deletions practices/ c/ level0/c1_1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <stdio.h>
int main()
{
int a;
printf("请输入一个数");
scanf("%d", &a);
if (a > 0)
{
printf("这个数是正数");
}
else if (a != 0)
{
printf("这个数是负数");
}
else printf("这个数既不是正数也不是负数");
if (0 == a % 2)
{
printf("这个数是偶数");
}
else printf("这个数是奇数");
}
13 changes: 13 additions & 0 deletions practices/ c/ level0/c1_2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <stdio.h>
int main()
{
int a;
printf("请输入一个数");
scanf("%d", &a);
if (0 == a % 13)
{
printf("这个数是13的倍数");
}
else
printf("这个数不是13的倍数");
}
11 changes: 11 additions & 0 deletions practices/ c/ level0/c1_3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <stdio.h>
int main()
{
int a;
printf("请输入年数");
scanf("%d", &a);
if ((0 == a % 4 && 0 != a % 100) || 0 == a % 400)
printf("这一年是闰年");
else
printf("这一年不是闰年");
}
20 changes: 20 additions & 0 deletions practices/ c/ level0/c1_5.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <stdio.h>
int main()
{
int a, b, c;
printf("请输入三个数");
scanf("%d%d%d", &a, &b, &c);
if (a > b)
{
if (c > a)
a = c;
}
else
{
if (b > c)
a = b;
else
a = c;
}
printf("这三个数中最大的是%d", a);
}
17 changes: 17 additions & 0 deletions practices/ c/ level0/c1_6.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <stdio.h>
int main()
{
int i,n,max_number=0;
printf("请输入要比较的数的个数");
scanf("%d", &n);
int number;
for (i = 0; i < n; i++)
{
scanf("%d", &number);
if (number > max_number)
{
max_number = number;
}
}
printf("这n个数中最大的数是%d", max_number);
}
12 changes: 12 additions & 0 deletions practices/ c/ level0/c2_1.1.1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <stdio.h>
int main()
{
int i;
for (i = 2; i <= 200; i++)
{
if (0 == i % 2)
{
printf("%d\t", i);
}
}
}
12 changes: 12 additions & 0 deletions practices/ c/ level0/c2_1.1.2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <stdio.h>
int main()
{
int i;
for (i = 1; i <= 100; i++)
{
if ((0 == i % 3) && (0 != i % 5))
{
printf("%d\t", i);
}
}
}
13 changes: 13 additions & 0 deletions practices/ c/ level0/c2_1.1.3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <stdio.h>
void main()
{
int i, sum = 0;
for (i = 1; i <= 100; i++)
{
if ((0 == i % 7) || (7 == i % 10))
{
printf("%d\t", i);
sum += i;
}
}
}
11 changes: 11 additions & 0 deletions practices/ c/ level0/c2_1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <stdio.h>
#include <windows.h>
void main()
{
int i,t=50;
for (i = 0; i < 10000; i++)
{
printf("你好");
Sleep(t);
}
}
13 changes: 13 additions & 0 deletions practices/ c/ level0/c2_2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <stdio.h>
void main()
{
system("color 0a");
while (1)
{
printf("0 1");
}
}
//结果分析
//结果:屏幕无限制打印绿色字体的‘0’、‘1’
//system ("color 0a")使字体变绿
//while 语句条件表达式为1,代表真,无限执行循环“打印绿色字体0 1”
117 changes: 117 additions & 0 deletions practices/ c/ level1/ font-font- p10_pushBoxes/ font/pushbox.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#define SIZE 9
int intmaze[SIZE][SIZE];
void print_map();
void scanfmap();
void move(int nn);
void main()
{
scanfmap();
move(SIZE);
system("pause");
}

void scanfmap()
{
FILE *p;
p =fopen("level1.txt", "r");
for (int i = 0; i < SIZE; i++) {
for (int j= 0; j < SIZE; j++) {
fscanf(p, "%d", &intmaze[i][j]);
}
}
fclose(p);
}
void print_map()
{
for (int i = 0; i < SIZE; i++) {
for (int j = 0; j < SIZE; j++) {
if (intmaze[i][j] == 0) {
intmaze[i][j] = ' '; //空格
}if (intmaze[i][j] == 1) {
intmaze[i][j] = '*'; //墙壁
}if (intmaze[i][j] == 9) {
intmaze[i][j] = 'P'; //人
}if (intmaze[i][j]== 2) {
intmaze[i][j] = '@'; //目的地;
}if (intmaze[i][j]== 3) {
intmaze[i][j] = '#'; //箱子
}
}
}
for (int i = 0; i < SIZE; i++) {
for (int j = 0; j < SIZE; j++) {
printf("%c", intmaze[i][j]);
}
printf("\n");
}
}

void move(int nn)
{
int x = 4, y = 4;
char walk;
while (1) {
print_map();
walk = _getch();
if (walk == 'w') {
if ((intmaze[x - 1][y] == ' ') && (x>0)) {
intmaze[x - 1][y] = 9;
intmaze[x][y] = 0;
x--;
}
else if ((intmaze[x - 1][y] == '#') && (intmaze[x - 2][y] != '*') && (x > 1)) {
intmaze[x - 1][y] = 9;
intmaze[x - 2][y] = 3;
intmaze[x][y] = 0;
x--;
}
}
if (walk == 's') {
if ((intmaze[x + 1][y] == ' ') && (x < nn - 1)) {
intmaze[x + 1][y] = 9;
intmaze[x][y] = 0;
x++;
}
else if ((intmaze[x + 1][y] == '#') && (intmaze[x + 2][y] != '*') && (x < nn - 2)) {
intmaze[x + 1][y] = 9;
intmaze[x + 2][y] = 3;
intmaze[x][y] = 0;
x++;
}
}
if (walk == 'a'){
if ((intmaze[x][y - 1] == ' ') && (y > 0)) {
intmaze[x][y - 1] = 9;
intmaze[x][y] = 0;
y--;
}
else if ((intmaze[x][y - 1] == '#') && (intmaze[x][y - 2] != '*') && (y>1)) {
intmaze[x][y - 1] = 9;
intmaze[x][y - 2] = 3;
intmaze[x][y] = 0;
y--;
}
}
if (walk == 'd') {
if ((intmaze[x][y + 1] == ' ') && (y < nn - 1)) {
intmaze[x][y + 1] = 9;
intmaze[x][y] = 0;
y++;
}
else if ((walk == 'd') && (intmaze[x][y + 1] == '#') && (intmaze[x][y + 2] != '*') && (y < nn - 2)) {
intmaze[x][y + 1] = 9;
intmaze[x][y + 2] = 3;
intmaze[x][y] = 0;
y++;
}
}
system("cls");
if (intmaze[1][4] != '@' && intmaze[4][1] != '@' && intmaze[7][4] != '@' && intmaze[4][7] != '@') {
printf("YOU WIN\n");
break;
}
}
}
26 changes: 26 additions & 0 deletions practices/ c/ level1/ p01_runningLetter/runningletter.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include<stdio.h>
#include<windows.h>
int for_back_word(int a);
const int n = 120;
int main()
{
int i;
for (i = 1; i < n; i++) {
for_back_word(i);
}
for (i; i > 0; i--) {
for_back_word(i);
}
return 0;
}

int for_back_word(int a)
{
int j,m=100;
for (j = 1; j < a; j++) {
printf(" ");
}
printf("R");
Sleep(m);
system("cls");
}
35 changes: 35 additions & 0 deletions practices/ c/ level1/ p02_isPrime/isprime.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include<stdio.h>
#include<math.h>
int is_prime(int a);
int main()
{
int x;
scanf_s("%d", &x);
if (is_prime(x)) {
printf("%d is a prime", x);
}
else {
printf("%d is not a prime", x);
}
return 0;
}

int is_prime(int a)
{
int k;
if (a == 1) {
return 0;
}if (a == 2) {
return 1;
}if (a > 2) {
for (k = 2; k <= sqrt(a); k++) {
if (a%k == 0) {
return 0;
break;
}
else {
return 1;
}
}
}
}
11 changes: 11 additions & 0 deletions practices/ c/ level1/ p03_Diophantus/Diophants.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include<stdio.h>
int main()
{
int x;
for (x = 1; x <= 150; x++) {
if (x*(1 / 6.0 + 1 / 7.0 + 1 / 12.0) + 5 + x / 2.0 + 4 == x) {
printf("%d", x-4);
}
}
return 0;
}
11 changes: 11 additions & 0 deletions practices/ c/ level1/ p03_Diophantus/Diophantus.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include<stdio.h>
int main()
{
int x;
for (x = 1; x <= 150; x++) {
if (x*(1 / 6.0 + 1 / 7.0 + 1 / 12.0) + 5 + x / 2.0 + 4 == x) {
printf("%d", x-4);
}
}
return 0;
}
Loading