-
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
再次尝试 #43
base: master
Are you sure you want to change the base?
再次尝试 #43
Changes from 3 commits
325566b
d32e9e8
c4f37f2
b2a8cc6
5fbf301
fe538e3
74c8110
660b967
af9913b
a70f336
5f064be
63ca7af
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,24 @@ | ||
#include<stdio.h> | ||
#include<windows.h> | ||
void main() | ||
{ | ||
int i,j; | ||
for (i = 0;i < 80;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. 循环变量放进去 |
||
Sleep(50); | ||
system("cls"); | ||
for (j = 0;j < i - 1;j++) { | ||
printf(" "); | ||
} | ||
printf("R"); | ||
|
||
} | ||
for (i = 80;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. 80应该定义一个常量 |
||
Sleep(50); | ||
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. 重复的味道,请消除之 |
||
system("cls"); | ||
for (j = 0;j < i - 1;j++){ | ||
printf(" "); | ||
} | ||
printf("R"); | ||
} | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include<stdio.h> | ||
int main() | ||
|
||
{ | ||
long int i, j; | ||
printf("Please input a number: \t"); | ||
scanf_s("%d", &i); | ||
if (i == 2) { | ||
printf("%d is a Prime.", i); | ||
} | ||
else if (i == 1) { | ||
printf("%d is not a Prime.", i); | ||
} | ||
else | ||
{ | ||
j = 2; | ||
while (i > j) | ||
{ | ||
if (i%j == 0) | ||
break; | ||
|
||
else | ||
{ | ||
if (i == j + 1) | ||
{ | ||
printf("%d is a Prime.", i); | ||
break; | ||
} | ||
j++; | ||
|
||
} | ||
} | ||
if (i > j + 1) | ||
printf("%d is not a Prime.", i); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include<stdio.h> | ||
int main() | ||
|
||
{ | ||
long int i, j; | ||
printf("Please input a number: \t"); | ||
scanf_s("%d", &i); | ||
if (i == 2) { | ||
printf("%d is a Prime.", i); | ||
} | ||
else if (i == 1) { | ||
printf("%d is not a Prime.", i); | ||
} | ||
else | ||
{ | ||
j = 2; | ||
while (i > j) | ||
{ | ||
if (i%j == 0) | ||
break; | ||
|
||
else | ||
{ | ||
if (i == j + 1) | ||
{ | ||
printf("%d is a Prime.", i); | ||
break; | ||
} | ||
j++; | ||
|
||
} | ||
} | ||
if (i > j + 1) | ||
printf("%d is not a Prime.", i); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include<stdio.h> | ||
int main() | ||
{ | ||
int i,j,k,l; | ||
for (i = 100;i < 1000;i++) | ||
{ | ||
k = i % 10; | ||
j = (i % 100) / 10; | ||
l = i / 100; | ||
if (i == (k*k*k) + (j*j*j) + (l*l*l)) | ||
{ | ||
printf("%5d", i); | ||
} | ||
} | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include<stdio.h> | ||
#include<time.h> | ||
int main() | ||
{ | ||
int j; | ||
double time; | ||
clock_t begin, end; | ||
begin = clock(); | ||
printf("%5d", 2); | ||
for (int num = 3;num <= 1000;num++){ | ||
j = 2; | ||
while (num > j){ | ||
if (num%j == 0) | ||
break; | ||
else{ | ||
if (num == j + 1){ | ||
printf("%5d", num); | ||
break; | ||
} | ||
j++; | ||
|
||
} | ||
} | ||
} | ||
end = clock(); | ||
time = (double)(end - begin)/ CLOCKS_PER_SEC; | ||
printf("\n\n����ʱ��Ϊ%f��", time); | ||
} | ||
|
||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include<stdio.h> | ||
void main() | ||
{ | ||
int t=1; | ||
int c[101] = { 0 }; | ||
int prime[26]; | ||
for (int a = 2;a <= 10;a++){ | ||
if (c[a] == 0){ | ||
for (int b = 2 * a;b <= 100;b += a) | ||
c[b] = 1; | ||
} | ||
} | ||
for (int a = 2;a <= 100;a++){ | ||
if (c[a] == 0) { | ||
prime[t] = a; | ||
t += 1; | ||
} | ||
} | ||
int m, n; | ||
for (m = 1;m <= 50;m++){ | ||
n = 2 * m; | ||
for (int p = 1;p <= 26;p++) { | ||
for (int d = 1;d <= p;d++) | ||
if (n == prime[p] + prime[d]) | ||
printf("%2d=%2d+%2d\t", n, prime[p], prime[d]); | ||
} | ||
} | ||
printf("\n\n"); | ||
if (m = 50)printf("��ˣ���100���ڸ�°ͺղ�����ȷ��"); | ||
else printf("��ˣ���100���ڸ�°ͺղ��벻��ȷ��"); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include<stdio.h> | ||
#include<stdlib.h> | ||
|
||
int main() | ||
{ | ||
int L = 5; | ||
int i; | ||
char k, ch; | ||
char* p = (char*)malloc(sizeof(char) * L); | ||
int count = 0; | ||
printf("��ѡ����������ܻ��ǽ���:a������ b������\n"); | ||
k = getch(); | ||
if (k == 'a') { | ||
printf("������������ܵ��ַ���: "); | ||
do | ||
{ | ||
ch = getchar(); | ||
count++; | ||
if (count >= L) { | ||
p = (char*)realloc(p, sizeof(char*) * (++L)); | ||
} | ||
p[count - 1] = (char)((int)ch + 4); | ||
} while (ch != '\n'); | ||
printf("��һ������%d���ַ�\n���ܺ������Ϊ��", count - 1); | ||
for (i = 0;i < count;i++) { | ||
printf("%c", p[i]); | ||
} | ||
free(p); | ||
} | ||
|
||
|
||
else if (k == 'b') { | ||
printf("������������ܵ��ַ���: "); | ||
do | ||
{ | ||
ch = getchar(); | ||
count++; | ||
if (count >= L) { | ||
p = (char*)realloc(p, sizeof(char*) * (++L)); | ||
} | ||
p[count - 1] = (char)((int)ch - 4); | ||
} while (ch != '\n'); | ||
printf("��һ������%d���ַ�\n���ܺ������Ϊ��", count - 1); | ||
for (i = 0;i < count;i++) { | ||
printf("%c", p[i]); | ||
} | ||
free(p); | ||
} | ||
else { | ||
printf("���������Ϣ����."); | ||
return 0; | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include<stdio.h> | ||
void han(int num, char a, char b, char c); | ||
|
||
int main() | ||
{ | ||
int num; | ||
printf("�����������ƶ��ĺ�ŵ��Բ��������"); | ||
scanf_s("%d", &num); | ||
printf("�ƶ�˳��Ϊ��\n"); | ||
han(num, 'a',' b',' c'); | ||
} | ||
|
||
void han(int num, char a, char b, char c) | ||
{ | ||
if (num == 1) { | ||
printf("%c�ƶ���%c\n", a, c); | ||
} | ||
else { | ||
han(num - 1, 'a',' c', 'b'); | ||
printf("%c�ƶ���%c\n", a, c); | ||
han(num - 1, 'b', 'a', 'c'); | ||
} | ||
} |
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.
加个空行,好看