-
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
摸索着交个作业... #45
base: master
Are you sure you want to change the base?
摸索着交个作业... #45
Changes from 19 commits
8ae0892
0d37b80
459abc5
5e4c664
52e5fc5
68ca0ec
e09e1bf
5c26851
07caa6d
e73f43b
3081dd5
afdfd69
bd64562
9736e55
836bce3
b961323
a05d35e
413d81a
af0a055
090a297
77b94ed
e7f3b34
6424039
2c66d56
494b468
d7d972a
a6cdf75
ba7b9ab
6b5d5b1
2fa1034
1e5c733
4521c43
de09a27
a2a2752
cb402e5
29a043e
ca447d6
3d551a1
b875fd9
a2de511
b7193bc
0662574
0d37747
daee9de
c5d1987
90eb3ba
3e6d9bd
587a0f5
4baf6a0
be41a2e
b501c1b
ceb67fc
79094cb
6f04154
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,23 @@ | ||
# include <stdio.h> | ||
|
||
int main() | ||
{ | ||
int input; | ||
scanf("%d",&input); | ||
|
||
if(input>0){ | ||
if(input%2==0){ | ||
printf("是正数而且是偶数\n"); | ||
} | ||
else { | ||
printf("是正数但不是偶数\n"); | ||
} | ||
} | ||
else if(input==0){ | ||
printf("既不是正数也不是负数\n"); | ||
} | ||
else{ | ||
printf("是负数\n"); | ||
} | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# include <stdio.h> | ||
|
||
int main() | ||
{ | ||
printf("Hello World! I'm 李帅锋!\n"); | ||
|
||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# include<stdio.h> | ||
# include<windows.h> | ||
|
||
int main() | ||
{ | ||
int i,j; | ||
for(i=0;i<12;i++){ | ||
for(j=0;j<i;j++){ | ||
printf(" "); | ||
} | ||
Sleep(100); | ||
printf("R"); | ||
system("cls"); | ||
} | ||
|
||
for(i=12;i>0;i--){ | ||
for(j=0;j<i;j++){ | ||
printf(" "); | ||
} | ||
Sleep(100); | ||
printf("R"); | ||
system("cls"); | ||
} | ||
|
||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# include<stdio.h> | ||
# include<windows.h> | ||
|
||
int main() | ||
{ | ||
int i,j; | ||
for(i=0;i<12;i++){ | ||
for(j=0;j<i;j++){ | ||
printf(" "); | ||
} | ||
Sleep(100); | ||
printf("R"); | ||
system("cls"); | ||
} | ||
|
||
for(i=12;i>0;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. smell! 闻到了重复的味道,这段代码与上面的非常相似,请设法消除之 |
||
for(j=0;j<i;j++){ | ||
printf(" "); | ||
} | ||
Sleep(100); | ||
printf("R"); | ||
system("cls"); | ||
} | ||
|
||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# include<stdio.h> | ||
|
||
int main() | ||
{ | ||
int i,x = 0; | ||
int infox=-1; | ||
scanf("%d",&x); | ||
|
||
for( i=2;i<x;i++){ | ||
if(x%i==0){ | ||
infox++; | ||
} | ||
} | ||
|
||
if(infox==-1){ | ||
printf("是素数\n"); | ||
} | ||
else { | ||
printf("不是素数\n"); | ||
} | ||
|
||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# include<stdio.h> | ||
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. 内容与前面的文件是一样,请删除一个 |
||
|
||
int main() | ||
{ | ||
int i,x = 0; | ||
int infox=-1; | ||
scanf("%d",&x); | ||
|
||
for( i=2;i<x;i++){ | ||
if(x%i==0){ | ||
infox++; | ||
} | ||
} | ||
|
||
if(infox==-1){ | ||
printf("是素数\n"); | ||
} | ||
else { | ||
printf("不是素数\n"); | ||
} | ||
|
||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include <stdio.h> | ||
|
||
int main(void) | ||
{ | ||
int age; | ||
// age/6+age/12+age/7+5 = age-age/2-4 | ||
|
||
age = 28*9/3; | ||
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. 这个不行哦 |
||
printf("when diophantus's child dead,diophantus was :%d years old.",age-4); | ||
|
||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <stdio.h> | ||
# include<math.h> | ||
|
||
int main(void) | ||
{ | ||
int shuixianshu; | ||
int baiwei,shiwei,gewei; | ||
|
||
printf("三位水仙数如下:\n"); | ||
|
||
for(int i = 100;i<1000;i++){ | ||
baiwei = i/100; | ||
shiwei = (i%100)/10; | ||
gewei = i%10; | ||
|
||
if(i==pow(baiwei,3)+pow(shiwei,3)+pow(gewei,3)){ | ||
shuixianshu = i; | ||
printf("%d\t",shuixianshu); | ||
} | ||
} | ||
|
||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# include <stdio.h> | ||
# include <math.h> | ||
|
||
int main() | ||
{ | ||
int number = 153; | ||
|
||
for(number=100;number<1000;number++){ | ||
|
||
int number1 = number/100; | ||
int number2 = (number%100)/10; | ||
int number3 = number%10; | ||
if(number==pow(number1,3)+pow(number2,3)+pow(number3,3)){ | ||
printf("%d\n",number); | ||
} | ||
} | ||
|
||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include <stdio.h> | ||
#include<time.h> | ||
|
||
int isPrimer(int num); | ||
|
||
int main() | ||
{ | ||
clock_t start,finish; | ||
start = clock(); | ||
int primer; | ||
|
||
|
||
for(int i = 2;i<=1000;i++){ | ||
primer = isPrimer(i); | ||
if(primer){ | ||
printf("%d\n",i); | ||
} | ||
} | ||
|
||
printf("the running time is:\t"); | ||
finish = clock(); | ||
double time = (double)(finish-start)*1000/CLOCKS_PER_SEC; | ||
printf("%lf ms",time); | ||
|
||
return 0; | ||
} | ||
|
||
int isPrimer(int num){ | ||
int result = 0; | ||
int cnt = 0; | ||
|
||
for(int i = 2;i<=sqrt(num);i++){ | ||
if(num%i==0) { | ||
cnt++; | ||
break; | ||
} | ||
} | ||
|
||
if(cnt==0){ | ||
result = 1; | ||
} | ||
|
||
return result; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# include<stdio.h> | ||
|
||
|
||
int main() | ||
{ | ||
int num; | ||
int fox = 0; | ||
for(num=2;num<2000;num++){ | ||
for(int i=2;i<num;i++){ | ||
if(num%i==0){ | ||
fox++; | ||
} | ||
} | ||
if(fox==0){ | ||
printf("%d\n",num); | ||
} | ||
fox=0; | ||
} | ||
|
||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include <stdio.h> | ||
#include<time.h> | ||
|
||
int isPrimer(int num); | ||
|
||
int main() | ||
{ | ||
int primer[25]; | ||
int cnt = 0; | ||
for(int i = 2;i<100;i++){ | ||
if(isPrimer(i)) { | ||
primer[cnt] = i; | ||
cnt++; | ||
} | ||
} | ||
|
||
for(int i=3;i<=100;i++){ | ||
if(i%2==0){ | ||
for(int m = 0;m<=25;m++){ | ||
for(int n = 0;n<=25;n++){ | ||
if(primer[m]+primer[n]==i){ | ||
printf("%d=%d+%d\n",i,primer[m],primer[n]); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
printf("So,we can learn that Goldbach's suspect is right in 0-100.\n"); | ||
return 0; | ||
} | ||
|
||
int isPrimer(int num){ | ||
int result = 0; | ||
int cnt = 0; | ||
|
||
for(int i = 2;i<=sqrt(num);i++){ | ||
if(num%i==0) { | ||
cnt++; | ||
break; | ||
} | ||
} | ||
|
||
if(cnt==0){ | ||
result = 1; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# include<stdio.h> | ||
|
||
int i= 0; | ||
|
||
int main() | ||
{ | ||
int N; | ||
printf("input positive integer N: "); | ||
scanf("%d",&N); | ||
|
||
move('a','b','c',N); | ||
|
||
printf("these are all steps!"); | ||
return 0; | ||
} | ||
|
||
void move(char str1,char str2,char str3,int n) | ||
{ | ||
if(n==1){ | ||
printf("the %dst step:\t",++i); | ||
printf("%c->%c\n",str1,str3); | ||
}else{ | ||
move(str1,str3,str2,n-1); | ||
printf("the %dst step:\t",++i); | ||
printf("%c->%c\n",str1,str3); | ||
move(str2,str1,str3,n-1); | ||
} | ||
} |
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.
这个文件不需要了,应该删掉