Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
618eed1
汉诺塔
MagicVicCoder Oct 2, 2023
82cf1ac
p02+p03+p04
MagicVicCoder Oct 2, 2023
8d7b549
p02+p03+p04
MagicVicCoder Oct 2, 2023
287a8ff
p09 单链表倒置+搜索
MagicVicCoder Oct 2, 2023
b90f2d8
p01
MagicVicCoder Oct 2, 2023
5275a44
p08 推箱子
MagicVicCoder Oct 2, 2023
2a14604
p02
MagicVicCoder Oct 2, 2023
608aacd
p03
MagicVicCoder Oct 2, 2023
5161018
p07
MagicVicCoder Oct 6, 2023
c642361
Update main.c
MagicVicCoder Dec 28, 2023
dff403a
Update main.c
MagicVicCoder Dec 28, 2023
84a4544
Update main.c
MagicVicCoder Dec 28, 2023
64b8044
Update README.md
MagicVicCoder Dec 28, 2023
8650ed0
Create NEURALNETWORK.c
MagicVicCoder Jan 1, 2024
de8e148
Update NEURALNETWORK.c
MagicVicCoder Jan 1, 2024
eadbcc6
Create AIchess.c
MagicVicCoder Jan 1, 2024
a2d4a4a
Create 实验报告
MagicVicCoder Jan 1, 2024
655c53f
Create PI.c
MagicVicCoder Jan 1, 2024
0354832
Create skiplist.c
MagicVicCoder Jan 1, 2024
e44cbac
Create create.c
MagicVicCoder Jan 1, 2024
2e63553
Create insert.c
MagicVicCoder Jan 1, 2024
5bf93d8
Create search.c
MagicVicCoder Jan 1, 2024
f047706
Create modify.c
MagicVicCoder Jan 1, 2024
0ffe103
Create delete.c
MagicVicCoder Jan 1, 2024
ae80ff6
Update NEURALNETWORK.c
MagicVicCoder Jan 1, 2024
0ef935f
Create destroy.c
MagicVicCoder Jan 1, 2024
28cd146
Create 标头.h
MagicVicCoder Jan 1, 2024
61dc608
Create anothermethod.c
MagicVicCoder Jan 1, 2024
ffb83ee
Update C语言学习笔记.md
MagicVicCoder Jan 1, 2024
e8f9674
Create levfing_path_GA.c
MagicVicCoder Jan 1, 2024
8f2e10a
Update levfing_path_GA.c
MagicVicCoder Jan 1, 2024
a5de514
Create GA.maze.c
MagicVicCoder Jan 1, 2024
1adb8f5
程序设计结课ppt
MagicVicCoder Jan 5, 2024
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
58 changes: 56 additions & 2 deletions level1/p01_running_letter/main.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,60 @@
#include <printf.h>
#include <stdio.h>
#include <windows.h>

#define RIGHT 00
Copy link
Owner

Choose a reason for hiding this comment

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

为什么是00不是0呢?有什么特别的讲究吗?

#define LEFT 1


HANDLE hd;
int width,dir=RIGHT;
void move(int x,int y)
Copy link
Owner

Choose a reason for hiding this comment

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

习惯上,我们只在前面写上函数原型,函数实现移到下面

{
COORD pos={x,y};
SetConsoleCursorPosition(hd,pos);
return;
Copy link
Owner

Choose a reason for hiding this comment

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

这个return是多余的吧

}
void GetSize()
{
CONSOLE_SCREEN_BUFFER_INFO info;
GetConsoleScreenBufferInfo(hd,&info);
width=info.srWindow.Right;
return;
Copy link
Owner

Choose a reason for hiding this comment

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

同上

}
int ne(int now)
{
if(dir==RIGHT)
Copy link
Owner

Choose a reason for hiding this comment

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

感觉可以简化为一行,反而逻辑更清晰

{
if(now!=width) return now+1;
else
{
dir=LEFT;
return now-1;
}
}
else
{
if(now) return now-1;
else
{
dir=RIGHT;
return now+1;
}
}
}

int main() {
printf("hello world!\n");
int now;
hd= GetStdHandle(STD_OUTPUT_HANDLE);
GetSize();
printf("a");
while(1)
{
move(now,0);
printf(" ");
now=ne(now);
move(now,0);
printf("a");
Sleep(25);
Copy link
Owner

Choose a reason for hiding this comment

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

幻数

}
return 0;
}
29 changes: 25 additions & 4 deletions level1/p02_is_prime/main.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
#include <printf.h>

int main() {
printf("hello world!\n");
#include<stdio.h>
int main()
{
int m,n;
int i;
int cnt=0;
int sum=0;
scanf("%d %d",&m,&n);
if(m==1){
m=2;}
Copy link
Owner

Choose a reason for hiding this comment

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

可以格式化一下

for(i=m;i<=n;i++){
int isprime=1;
int k;
for(k=2;k<i-1;k++){
if(i%k==0){
isprime=0;
break;
}
}
if(isprime){
cnt++;
sum+=i;
}
}
printf("%d %d\n",cnt,sum);
return 0;
}
53 changes: 51 additions & 2 deletions level1/p03_all_primes/main.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,55 @@
#include <printf.h>
#include <stdio.h>

int main() {
printf("hello world!\n");
int i,x,cnt,num=0;
int a[100];
for(i=2;i<=100;i++){
cnt=0;
for(x=2;x<=i;x++){
cnt++;
if(i%x==0){
break;
}
}
if(cnt==i-1) {
printf("%d\n", i);
num++;
a[num-1]=i;
}
else
continue;
}
printf("num=%d\n",num);
int t,k,j,m,n,CNT=0;
for(t=6;t<=100;t++){
Copy link
Owner

Choose a reason for hiding this comment

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

感觉逻辑有点乱,不能一目了然

// printf("%d->%d\n",t,CNT);
for(i=0;i<num;i++){
if(a[i]<t){
k=t-a[i];
for(j=0;j<num;j++){
m=k-a[j];
for(n=0;n<num;n++){
if(a[n]==m){
CNT++;
goto end;
}else{
continue;
}

}

}
}
else{
break;
}
}
end:continue;
}
printf("CNT=%d\n",CNT);
if(CNT==95){
printf("right");
}

return 0;
}
53 changes: 51 additions & 2 deletions level1/p04_goldbach/main.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,55 @@
#include <printf.h>
#include <stdio.h>

int main() {
printf("hello world!\n");
int i,x,cnt,num=0;
int a[100];
for(i=2;i<=100;i++){
cnt=0;
for(x=2;x<=i;x++){
cnt++;
if(i%x==0){
break;
}
}
if(cnt==i-1) {
printf("%d\n", i);
num++;
a[num-1]=i;
}
else
continue;
}
printf("num=%d\n",num);
int t,k,j,m,n,CNT=0;
for(t=6;t<=100;t++){
// printf("%d->%d\n",t,CNT);
for(i=0;i<num;i++){
if(a[i]<t){
k=t-a[i];
for(j=0;j<num;j++){
m=k-a[j];
for(n=0;n<num;n++){
Copy link
Owner

Choose a reason for hiding this comment

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

嵌套太深

if(a[n]==m){
CNT++;
goto end;
}else{
continue;
}

}

}
}
else{
break;
}
}
end:continue;
}
printf("CNT=%d\n",CNT);
if(CNT==95){
printf("right");
}

return 0;
}
17 changes: 12 additions & 5 deletions level1/p05_encrypt_decrypt/main.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#include <printf.h>

int main() {
printf("hello world!\n");
#include<stdio.h>
int main(){
char a[26];
a[0]='a';
int i,x;
i=1;
while(i<26){
a[i]=a[i-1]+1;
}
for(i=0;i<26;i++)
printf("%c",a[i]);
return 0;
}
}
30 changes: 26 additions & 4 deletions level1/p06_hanoi/main.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
#include <printf.h>
#include <stdio.h>

int main() {
printf("hello world!\n");
return 0;
//定义move函数,将一个盘子从x座移到y座上
void move(char x, char y)
{
printf("%c-->%c\n",x,y); //输出移盘方案。x,y代表A,B,C座之一,根据每次的不同情况分别取A,B,C代入
}

void hanoi(int n, char one, char two, char three) //将n个盘从one座借助two座,移到three座
{
if(n==1)
move(one, three);
else
{
hanoi(n-1, one, three, two); //将 A 座上 n-1 个盘子移到 B 座上(借助 C)
move(one, three);//将 A 座上剩下的 1 个盘子移到 C 座上
hanoi(n-1, two, one, three);//将 B 座上 n-1 个盘子移到 C 座上(借助 A)
}
}

main()
{
int m;
printf("input the number of disks:");
scanf("%d",&m); //盘子的数量
printf("The step to moving %d disks:\n",m);
hanoi(m,'A','B','C');
}
Loading