-
Notifications
You must be signed in to change notification settings - Fork 78
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
完成了running letter #34
base: master
Are you sure you want to change the base?
Changes from 10 commits
a87f783
063e6c1
025e432
b9483e2
056caae
79f0202
fc79a9c
0b548db
b392a87
9b5b44a
4517ec5
3ce2453
23f8328
794ae15
98316cc
70555e7
e766926
920fc59
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,29 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#define LENGTH 119 | ||
int main(int argc, char *argv[]) | ||
{ | ||
int i,j,k; | ||
for(i=1;i<=LENGTH;i++) | ||
{ | ||
printf("a"); | ||
system("cls"); | ||
for(j=1;j<=i;j++) | ||
{ | ||
printf(" "); | ||
} | ||
} | ||
for(i=LENGTH;i>=1;i--) | ||
{ | ||
printf("a"); | ||
system("cls"); | ||
for(j=i;j>=1;j--) | ||
{ | ||
printf(" "); | ||
} | ||
} | ||
system("cls"); | ||
printf("a"); | ||
system("pause"); | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
int main(int argc, char *argv[]) | ||
{ | ||
int i,n,k; | ||
k=1; | ||
loop:scanf("%d",&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. 尽量不用goto,可尝试用while来代替 |
||
if(n<=0) | ||
{ | ||
printf("������һ��������\n"); | ||
goto loop; | ||
} | ||
for(i=2;i<n;i++) | ||
{ | ||
if(n%i==0) | ||
{ | ||
k=0; | ||
} | ||
} | ||
if(k==0||n==1||n==2) | ||
{ | ||
printf("��������\n"); | ||
} | ||
else | ||
printf("������\n"); | ||
system("pause"); | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
int main(int argc, char *argv[]) | ||
{ | ||
float x; | ||
for(x=1;x<=100;x++) | ||
{ | ||
if(x*1/6+x*1/12+x*1/7+5+0.5*x+4==x) | ||
{ | ||
printf("��ʱ����ͼ%.0f��\n",x-4); | ||
} | ||
} | ||
system("pause"); | ||
return 0; | ||
} |
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[]) | ||
{ | ||
int i,a,b,c,n; | ||
printf("3λˮ�ɻ�����\n"); | ||
for(i=100;i<=999;i++) | ||
{ | ||
a=i/100; | ||
b=(i/10)%10; | ||
c=i%10; | ||
if(i==a*a*a+b*b*b+c*c*c) | ||
printf("%d=%d^3+%d^3+%d^3\n",i,a,b,c); | ||
} | ||
system("pause"); | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include <stdio.h> | ||
#include <time.h> | ||
#include <stdlib.h> | ||
#include <math.h> | ||
#define N 2000 | ||
bool prime(int n) | ||
{ | ||
int i,k; | ||
k=1; | ||
for(i=2;i<sqrt(n);i++) | ||
{ | ||
if(n%i==0) | ||
{ | ||
k=0; | ||
} | ||
} | ||
return k; | ||
} | ||
int main(int argc, char *argv[]) | ||
{ | ||
int i,s; | ||
clock_t start, finish; | ||
double Total_time; | ||
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. 缩进 |
||
start = clock(); | ||
for(i=2;i<=N;i++) | ||
{ | ||
if(prime(i)==1) | ||
{ | ||
printf("%d ",i); | ||
} | ||
} | ||
printf("\n"); | ||
finish = clock(); | ||
Total_time = (double)(finish-start) / CLOCKS_PER_SEC; | ||
printf( "time:%f seconds\n", Total_time); | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <stdio.h> | ||
#include <math.h> | ||
bool prime(int n) | ||
{ | ||
int i,k; | ||
k=1; | ||
for(i=2;i<sqrt(n);i++) | ||
{ | ||
if(n%i==0) | ||
{ | ||
k=0; | ||
} | ||
} | ||
return k; | ||
} | ||
int main(int argc, char *argv[]) | ||
{ | ||
int i,j,t,n,s; | ||
for(i=4;i<=100;i=i+2) | ||
{ | ||
for(j=2;j<i;j++) | ||
{ | ||
if((prime(j)==1)&&(prime(i-j)==1)) | ||
{ | ||
printf("%d=%d+%d\n",i,j,i-j); | ||
} | ||
} | ||
} | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
#define LENGTH 100000 | ||
//�˼��ܷ���Ϊ���ַ���ASCII��+5 | ||
int encrypt(char s[]) | ||
{ | ||
int a[LENGTH]; | ||
int i; | ||
for(i=1;i<=LENGTH;i++) | ||
{ | ||
a[i]=-1; | ||
} | ||
for(i=0;i<strlen(s);i++) | ||
{ | ||
a[i]=s[i]; | ||
} | ||
for(i=0;i<strlen(s);i++) | ||
{ | ||
if(a[i]!=-1) | ||
{ | ||
a[i]=a[i]+5; | ||
} | ||
} | ||
for(i=0;i<strlen(s);i++) | ||
{ | ||
s[i]=(char)a[i]; | ||
} | ||
return 0; | ||
} | ||
int decrypt(char s[]) | ||
{ | ||
int b[LENGTH]; | ||
int x; | ||
for(x=1;x<=LENGTH;x++) | ||
{ | ||
b[x]=-1; | ||
} | ||
for(x=0;x<strlen(s);x++) | ||
{ | ||
b[x]=s[x]; | ||
} | ||
for(x=0;x<strlen(s);x++) | ||
{ | ||
if(b[x]!=-1) | ||
{ | ||
b[x]=b[x]-5; | ||
} | ||
} | ||
for(x=0;x<strlen(s);x++) | ||
{ | ||
s[x]=(char)b[x]; | ||
} | ||
return 0; | ||
} | ||
int main(int argc, char *argv[]) | ||
{ | ||
char s[LENGTH]="null"; | ||
int i; | ||
scanf("%[^\n]",s); | ||
encrypt(s); | ||
printf("���ܺ�%s\n",s); | ||
decrypt(s); | ||
printf("���ܺ�%s\n",s); | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <time.h> | ||
void hanoi(int n,char a,char b,char c) | ||
{ | ||
if(n==1) | ||
printf("%c��%c\n",a,c); | ||
else | ||
{ | ||
hanoi(n-1,a,c,b); | ||
printf("%c��%c\n",a,c); | ||
hanoi(n-1,b,a,c); | ||
} | ||
} | ||
int main(int argc, char *argv[]) | ||
{ | ||
int n; | ||
printf("��������������"); | ||
scanf("%d",&n); | ||
clock_t start, finish; | ||
double Total_time; | ||
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. 缩进 |
||
start = clock(); | ||
hanoi(n,'A','B','C'); | ||
finish = clock(); | ||
Total_time = (double)(finish-start) / CLOCKS_PER_SEC; | ||
printf( "����ʱ�䣺%f seconds\n", Total_time); | ||
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.
文件名尽量避免用中文