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

yutao #49

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
28 changes: 28 additions & 0 deletions level1/0runningLetter.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <stdio.h>
#include <unistd.h>
#define COLUMN 80

int main(){
int blank,location;

for (location = 1; location <=COLUMN ; location++){
for (blank=1; blank < location; blank++){
printf(" ");
}
putchar('A');
usleep(2000000);
Copy link
Owner

Choose a reason for hiding this comment

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

定义常量

system("clear");
}
for (location = location-1; location >=1; location--){
Copy link
Owner

Choose a reason for hiding this comment

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

闻到了重复的味道,请消除之

for (blank=1; blank < location; blank++){
printf(" ");
}
putchar('A');
usleep(200000);
system("clear");
}
return 0;
}



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

int main()
{
int x;
for(x=1; x<150; x++){
if(x/6 + x/12 + x/7 + 5 + x/2 + 4 ==x)
break;
}
printf("The father had lived for %d years.\n",x);
return 0;
}
22 changes: 22 additions & 0 deletions level1/allPrime.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <stdio.h>
#include <math.h>
#include <time.h>

int main()
{
int i,j;
long begin,end;

begin = time(NULL);
printf("\nThe primes are:\n%-7d",2);
for (i=3; i<1000; i=i+2){
for (j=3; j<=(int)sqrt(i); j=j+2)
if (i%j == 0) break;
Copy link
Owner

Choose a reason for hiding this comment

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

加大括号

if (j > (int)sqrt(i) ) printf("%-7d",i);
}
end = time(NULL);
printf("\nThe begin time is: %d.",begin);
printf("\nThe end time is: %d.",end);
printf("\nThe total time is: %lf seconds.",(end-begin)/1000000.0);
return 0;
}
23 changes: 23 additions & 0 deletions level1/isPrime.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <stdio.h>
#include <math.h>

int main()
{
int i,num;

printf("\nPlease enter a number: ");
scanf("%d",&num);
if (num == 2)
printf("\nIt's a prime.\n");
else{
for (i=2; i<=sqrt(num); i=i+2){
if (num % i==0){
printf("\nIt's not a prime.\n");
break;
}
}
if (i > sqrt(num))
printf("\nIt's a prime.\n");
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;
}
14 changes: 14 additions & 0 deletions level1/narcissus.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <stdio.h>

int main()
{
int i,ones,tens,hundreds;
for (i=100; i<1000; i++){
ones = i % 10;
tens = i/10 %10;
hundreds = i/100;
if (ones*ones*ones + tens*tens*tens + hundreds*hundreds*hundreds == i)
printf("%7d\n",i);
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;
}