-
Notifications
You must be signed in to change notification settings - Fork 35
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
base: master
Are you sure you want to change the base?
yutao #49
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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); | ||
system("clear"); | ||
} | ||
for (location = location-1; location >=1; location--){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
} | ||
|
||
|
||
|
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; | ||
} |
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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
} |
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"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 大括号 |
||
} | ||
return 0; | ||
} |
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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 大括号 |
||
} | ||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
定义常量