Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 27 additions & 0 deletions level1/p01_runningLetter/running_letter_Kitaibel.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <stdio.h>
#include <time.h>
#include <windows.h>
#define side_length 79
#define go printf("%s",str),Sleep(30),system("cls"),str[i]=' '
int main(int argc, char *argv[])
{
system("mode con cols=80 lines=20");
char str[100]={};
int i=0;
str[0]='a';
while(1)
{
for(i=0;i<side_length;i++)
{
go;
str[i+1]='a';
}
for(i=side_length;i>0;i--)
{
go;
str[i-1]='a';
}
}
system("pause");
return 0;
}
32 changes: 32 additions & 0 deletions level1/p02_isPrime/isPrime_Kitaibel.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#inc#include <stdio.h>
#include <math.h>

int main(int argc, char *argv[])
{
long long int n,i;
printf("����һ����������");
scanf("%lld",&n);
if(n==1)
{
printf("1��������");
return 0;
}

if(n==2)
{
printf("2������");
return 0;
}

for(i=2;i<sqrt(n)+1;i++)
{
if(n%i==0)
{
printf("%lld��������",n);
return 0;
}
}

printf("%lld������",n);
return 0;
}
17 changes: 17 additions & 0 deletions level1/p03_Diophantus/Diophantus_Kitaibel.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
float i;

for(i=1.0;;i++)
{
if(i/6+i/12+i/7+5+i/2+4==i)
{
printf("%.0f",i-4);
exit(0);
}
}

return 0;
}
21 changes: 21 additions & 0 deletions level1/p04_narcissus/Narcissus_Kitaibel.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
int a,b,c;
for(a=1;a<=9;a++)
{
for(b=0;b<=9;b++)
{
for(c=0;c<=9;c++)
{
if(a*a*a+b*b*b+c*c*c==a*100+b*10+c)
{
printf("%d%d%d\n",a,b,c);
}
}
}
}
return 0;
}
File renamed without changes.
37 changes: 37 additions & 0 deletions level1/p05_allPrimes/allPrime_Kitaibel.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char *argv[])
{
int a[200],i,m,judge=1;
int Tstart=clock();
a[0]=2;
printf("2\n");
a[1]=3;
for(i=1;;)
{
for(m=0;m<i;m++)
{
if(a[i]%a[m]==0)
{
judge=0;
break;
}
}
if(judge==1)
{
printf("%d\n",a[i]);
++i;
a[i]=a[i-1];
}
if(a[i]==1000)
{
break;
}
a[i]++;
judge=1;
}
int Tend=clock();
printf("Total time:%dms",Tend-Tstart);
return 0;
}
37 changes: 37 additions & 0 deletions level1/p06_Goldbach/Goldbach_Kitaibel.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char *argv[])
{
int a[200],i,m,judge=1;
int Tstart=clock();
a[0]=2;
printf("2\n");
a[1]=3;
for(i=1;;)
{
for(m=0;m<i;m++)
{
if(a[i]%a[m]==0)
{
judge=0;
break;
}
}
if(judge==1)
{
printf("%d\n",a[i]);
++i;
a[i]=a[i-1];
}
if(a[i]==1000)
{
break;
}
a[i]++;
judge=1;
}
int Tend=clock();
printf("Total time:%dms",Tend-Tstart);
return 0;
}
46 changes: 46 additions & 0 deletions level1/p07_encrypt_decrypt/encrypt_decrypt_Kitaibel.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void encrypt(char *str,int len);
void decrypt(char *str,int len);

int main(int argc, char *argv[])
{
int i,m;
char str[100];
printf("����������1������������2��");
scanf("%d",&i);
printf("��������������ַ�����");
scanf("%s",str);
m=strlen(str);
if(i==1)
{
encrypt(str,m);
}
if(i==2)
{
decrypt(str,m);
}

return 0;
}

void encrypt(char *str,int len)
{
int n;
for(n=0;n<len;n++)
{
str[n] +=5;
}
puts(str);
}
void decrypt(char *str,int len)
{
int n;
for(n=0;n<len;n++)
{
str[n] -=5;
}
puts(str);
}
35 changes: 35 additions & 0 deletions level1/p08_hanoi/hanoi_Kitaibel.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <stdio.h>

void hanoi(int n, char a,char b,char c);
void move(int n, char a, char b);

int count;

int main()
{
int n=8;
printf("�����뺺ŵ���IJ���:");
scanf("%d",&n);
hanoi(n, 'A', 'B', 'C');
return 0;
}

void hanoi(int n, char a, char b, char c)
{
if (n == 1) //�ѵ�n��������A�Ƶ�C
{
move(n, a, c);
}
else //��n-1��������A�Ƶ�B
{
hanoi(n - 1, a, c, b);
move(n, a, c);
hanoi(n - 1, b, a, c);
}
}

void move(int n, char a, char b)
{
count++;
printf("��%d��:��%c�Ƶ�%c\n",count,a,b);
}
127 changes: 127 additions & 0 deletions level1/p09_maze/maze_Kitaibel.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>

void UP();
void DOWN();
void LEFT();
void RIGHT();
int JudgeObstacle();
void PRTmaze();

int x=1,y=1; //��������
int judgeRE;

char a[13][31]={"##############################",
"#O #### ############",
"##### #### #### ##############",
"# #### #### ##############",
"##### #### ##############",
"############### ##############",
"############### #############",
"################ ###########",
"################## ###########",
"################## ###########",
"################## #######",
"###################### ",
"##############################"};

int main(int argc, char *argv[])
{
system("color f0");

PRTmaze();

int ch;
while( (ch=getch())!=0x1B )
{
switch(ch)
{
case 0xE0:
switch(ch=getch())
{
case 72: UP(); break;
case 80: DOWN(); break;
case 75: LEFT(); break;
case 77: RIGHT(); break;
default:continue;
}
if(x==11 && y==29)
{
MessageBox(NULL,"��ϲͨ��","Success",MB_OK);
exit(0);
}
break;
default:
continue;
}
}

return 0;
}

void UP()
{
if(JudgeObstacle(x-1,y))
{
a[x][y]=' ';
--x;
a[x][y]='O';
}
else
{

}
PRTmaze();
}

void DOWN()
{
if(JudgeObstacle(x+1,y))
{
a[x][y]=' ';
++x;
a[x][y]='O';
}
PRTmaze();
}

void LEFT()
{
if(JudgeObstacle(x,y-1))
{
a[x][y]=' ';
--y;
a[x][y]='O';
}
PRTmaze();
}

void RIGHT()
{
if(JudgeObstacle(x,y+1))
{
a[x][y]=' ';
++y;
a[x][y]='O';
}
PRTmaze();
}

int JudgeObstacle(int X,int Y)
{
if(a[X][Y]==' ')
return 1;
else
return 0;
}

void PRTmaze()
{
system("cls");
int i;
for(i=0;i<=12;i++)
{
printf("%s\n",a[i]);
}
}
Loading