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

Homework from Liangzhenwen #52

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 18 additions & 0 deletions Diophantus.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <stdio.h>
int main(int argc, char** argv)
{
int fatherAge=0;
for(double i=1.0;i<100;i++) //��������
{
for(double j=1;j<200;j++) //��������
{
if((1.0/6.0*j+1.0/12.0*j+1.0/7.0*j+5+i+4==j)&&(2*i==j))
{
fatherAge=j;
break;
}
}
}
printf("������ʱ����ͼ����Ϊ%d",FatherAge-4);
return 0;
}
52 changes: 52 additions & 0 deletions Encrypted.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

void Encrypte(char* p)
{
int i = 0;
while (p[i] != '\0')
{
p[i] = p[i] + '3' - '1';
printf("%c", p[i]);
i++;
}
printf("\n");
}

void Decrypte(char* p)
{
int i = 0;
while (p[i] != '\0')
{
p[i] = p[i] - '3' + '1';
printf("%c", p[i]);
i++;
}
printf("\n");
}

int main()
{
char p[10000];
int Judge = 0;
printf("Please input the string need opreating\n");
scanf("%s", p);
printf("En or De?\nPleaes input 1(En) or 2(De)\n");
scanf("%d", &Judge);
if (Judge == 1)
{
Encrypte(p);
}
else if (Judge == 2)
{
Decrypte(p);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

对于if elseif结构,最后要有一个else接住剩下的情况,这里就可以提示用户输入不对,只能输入1或者2

else
{
printf("Input Error!");
return -1;
}
return 0;
}

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

/*int pd(int n)
{
for(int i=2;i<=n/2;i++) //This program is used for drawing a table
{
if(n%i==0)
return 0;
}
return 1;
}


int main(int argc, char** argv)
{
int a[100];
int tot=0;
printf("a[0]=2\n");
for(int i=3;i<100;i++)
{
if(pd(i))
{
a[tot++]=i;
printf("a[%d]=%d;\n",tot,i);
}
}
return 0;
} */

int main()
{
int a[25]; //���
int judge = 0;
a[0] = 2;
a[1] = 3;
a[2] = 5;
a[3] = 7;
a[4] = 11;
a[5] = 13;
a[6] = 17;
a[7] = 19;
a[8] = 23;
a[9] = 29;
a[10] = 31;
a[11] = 37;
a[12] = 41;
a[13] = 43;
a[14] = 47;
a[15] = 53;
a[16] = 59;
a[17] = 61;
a[18] = 67;
a[19] = 71;
a[20] = 73;
a[21] = 79;
a[22] = 83;
a[23] = 89;
a[24] = 97;
Copy link
Collaborator

Choose a reason for hiding this comment

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

哈哈,一个个写的呀,好累哦。这种脏活累活就交给计算机来处理嘛 2333

for (int i = 4; i <=100; i+=2)
{
for (int j = 0; j < 25; j++)
{
for (int k = 0; k < 25; k++)
{
if (a[j] + a[k] == i)
{
judge = 1;
break;
}
}
if (judge==1)
{
cout << i << "�����°ͺղ���" << endl;
break;
}
else if (judge==0)
{
return -1;
printf("Goldbach do not exists");
}
judge = 0;
}
return 0;
}

34 changes: 34 additions & 0 deletions Running Letter.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <stdio.h>
#include <windows.h>

int main(int argc, char** argv)
{
int i = 0;
int j = 0;
while (1)
{
printf("R");
Sleep(30);
system("cls");
int op = 1;
for (i = 0; i<79&&i>=0; i+=op)
{
for (j = 0; j < i; j++)
{
printf(" ");
}
printf("R");
Sleep(30);
system("cls");
if (i == 78)
{
op = -1;
}
if (i == 0)
{
op = 1;
}
}
}
return 0;
}
Loading