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
1,006 changes: 1,006 additions & 0 deletions final/main.c

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions final/readme
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

55 changes: 55 additions & 0 deletions level1/p01_runningLetter/running letter.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include<stdio.h>

#include<stdlib.h>

#include <windows.h>

int main()

{

char c[100];

gets(c);

while(1)

{

for(int i=1;i<=115;i++)

{

for(int j=1;j<i;j++)

printf(" ");

printf("%s",c);

Sleep(20);

system("CLS");

}

for(int k=114;k>=1;k--)

{

for(int j=1;j<=k;j++)

printf(" ");

printf("%s",c);

Sleep(20);

system("CLS");

}

}

return 0;

}
29 changes: 29 additions & 0 deletions level1/p01_runningLetter/running letter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include<stdio.h>
#include<stdlib.h>
#include <windows.h>
int main()
{
int number=115;
char c[100];
gets(c);
while(1)
{
for(int i=1;i<=number;i++)
{
for(int j=1;j<i;j++)
printf(" ");
printf("%s",c);
Sleep(20);
system("CLS");
}
for(int k=number-1;k>=1;k--)
{
for(int j=1;j<=k;j++)
printf(" ");
printf("%s",c);
Sleep(20);
system("CLS");
}
}
return 0;
}
31 changes: 31 additions & 0 deletions level1/p02_isPrime/isprime.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[])
{
long int num;
while(scanf("%d",&num)==1)
{
if(num==1)
printf("%ld��������\n",num);
if(num==2)
printf("%ld������\n",num);
if(num>2)
{
int i=2;
for(;i<num;i++)
{
if(num%i==0)
{
printf("%ld��������\n",num);
break;
}
}
if(i==num)
printf("%ld������\n",num);
}
}
return 0;
}
24 changes: 24 additions & 0 deletions level1/p03_Diophantus/p03.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[])
{
int i=1;
for(;i<150;i++)
{
if((i%6==0)&(i%12==0)&(i%7==0))
{
int sonlife,falife,marry,sonbirth;
falife=i;
sonlife=0.5*(i-4);
marry=i/6+i/12+i/7;
sonbirth=marry+5;
if(sonlife=(falife-4-sonbirth))
printf("When his son passed away, he was %d.\n",falife-4);

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

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[])
{
int a,b,c;
for(int i=1;;i++)
{
if(i<100)continue;
if(i>999) break;
a=i/100;
b=i/10%10;
c=i%10;
if(i==(a*a*a+b*b*b+c*c*c)) printf("%d\n",i);
}
return 0;
}
22 changes: 22 additions & 0 deletions level1/p05_allPrimes/p05.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <stdio.h>
#include <stdlib.h>
#include<time.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[])
{
int i=2;
printf("%d\n",i);
for(int i=3;i<1001;i++)
{
int j=2;
for(;j<i;j++)
{
if(i%j==0)
break;
}
if(j==i)printf("%d\n",i);
}
printf("%dms\n",clock());
return 0;
}
39 changes: 39 additions & 0 deletions level1/p06_Goldbach/p06.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <stdio.h>
#include <stdlib.h>
#define maxn 100
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[])
{
int prime[maxn];
prime[0]=2;
int count=1;
for(int i=3;i<maxn+1;i++)
{
int j=2;
for(;j<i;j++)
{
if(i%j==0)
break;
}
if(j==i)
{
prime[count]=i;
count=count+1;
}
}
for(int t=4;t<=maxn+1;t=t+2)
{
for(int u=0;u<count;u++)
{
for(int p=0;p<count;p++)
{
if(t==(prime[u]+prime[p]))
{
printf("%d=%d+%d\n",t,prime[u],prime[p]);
}
}
}
}
return 0;
}
19 changes: 19 additions & 0 deletions level1/p07_encrypt_decrypt/p07.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[])
{
int c;
while((c=getchar())!=EOF)
{
if(c>='A'&&c<='Z')
c=c+2;
if(c>='a'&&c<='z')
c=c-3;
else c=c+4;
printf("%c",c);
}
return 0;
}
19 changes: 19 additions & 0 deletions level1/p07_encrypt_decrypt/p07ex.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[])
{
int c;
while((c=getchar())!=EOF)
{
if(c>=67&&c<=92)
c=c-2;
if(c>=94&&c<=119)
c=c+3;
else c=c-4;
printf("%c",c);
}
return 0;
}
26 changes: 26 additions & 0 deletions level1/p08_hanoi/p08.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

void move (int n, char a, char b, char c)
{
if (n == 1)
{
printf("%c-->%c\n",a,c);
}
else
{
move (n-1,a,c,b);
printf("%c-->%c\n",a,c);
move (n-1,b,a,c);
}
}

int main(int argc, char *argv[])
{
int n;
scanf("%d",&n);
move(n,'A','B','C');
return 0;
}
Loading