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

ruuning letter 完成 #41

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
32 changes: 32 additions & 0 deletions level1/p01_runningLetter/level1_1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
#define WIDTH 20
int main()
{
int x,y,z,s,w;
char a[WIDTH];
for(x=1;x<=100;x++)

{
if (x%2==1)
{
w=1;
}
Copy link
Owner

Choose a reason for hiding this comment

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

缩进不对

else
{
w=-1;
}
{for(y=WIDTH*(1-w)/2;y!=WIDTH*(1+w)/2;y+=w)
Copy link
Owner

Choose a reason for hiding this comment

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

for语句新起一行

{for(z=0;z<y;z++)
Copy link
Owner

Choose a reason for hiding this comment

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

缩进代表代码的层次结构,要重视;
提示:空格和tab不宜混用,因为不同的环境对tab键对应的空格数是不一样的;
ps:比较好一点的IDE,一般都有format工具可以用

{
putchar(' ');
}
printf("%c\n",'A');
Sleep(100);
system("cls");
}
}

}
}
25 changes: 25 additions & 0 deletions level1/p02_isPrime/level1_2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include<stdio.h>
#include<math.h>
int main()
{
int x,y,z,w;
w=0;
printf("Plesse input a integer:\n");
scanf("%d",&x);
y=sqrt(x);
for(z=2;z<=y;z++)
{
if((x/z*z)==x)
w=1;
}

if(w!=0)
{
printf("%d is not prime\n",x);
}
else
{
printf("%d is prime\n",x);
}
return 0;
}
11 changes: 11 additions & 0 deletions level1/p03_Diophantus/level1_3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include<stdio.h>
int main()
{
float x;
for(x=4;x<200;x++)
if(x/6+x/12+x/7+5+x/2+4==x)
{
printf("age=%.0f\n",x);
}
return 0;
}
17 changes: 17 additions & 0 deletions level1/p04_ narcissus/level1_4.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include<stdio.h>
int main()
{
int x,a,b,c;
printf("Narcissistic numbes between 100~999 are as follows:");
for(x=100;x<=999;x++)
{
a=x/100;
b=(x-a*100)/10;
c=x%10;
if(a*a*a+b*b*b+c*c*c==x)
{
printf(" %d",x);
}
}
return 0;
}