-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Player
authored and
Player
committed
Apr 14, 2017
1 parent
8c8fb4f
commit f018503
Showing
78 changed files
with
1,393 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <stdio.h> | ||
int main() | ||
{ | ||
printf("hello world."); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#include <stdio.h> | ||
int main( string[ ] ) |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,4 @@ int main(void) | |
{ | ||
three_hellos(); | ||
return 0; | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,38 @@ | ||
/************************************************************************* | ||
> File Name: 1-35.c | ||
> Author: Tony | ||
> Mail: shouqitao@163.com | ||
> Created Time: Wed Sep 14 23:12:33 2016 | ||
************************************************************************/ | ||
|
||
#include <stdio.h> | ||
|
||
int main(int argc, char *argv[]) { | ||
int len=0; | ||
char *p=s; | ||
while(*p!=0) | ||
{ | ||
len++; | ||
p++; | ||
} | ||
} | ||
void reverse(char *s) | ||
{ | ||
int len = 0; | ||
char *p = s; | ||
while(*p != 0) | ||
{ | ||
len++; | ||
p++; | ||
} | ||
|
||
int i = 0; | ||
char c; | ||
while(i <= len/2 -1) | ||
{ | ||
c=*(s+i); | ||
*(s+i)=*(s+len-1-i); | ||
*(s+len-1-i)=c; | ||
i++; | ||
} | ||
} | ||
|
||
int main() | ||
{ | ||
char s[]="www.runoob.com"; | ||
printf("'%s' =>\n",s); | ||
reverse (s); | ||
printf("'%s'\n",s); | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/************************************************************************* | ||
> File Name: 1-36.c | ||
> Author: Tony | ||
> Mail: shouqitao@163.com | ||
> Created Time: Wed Sep 14 23:20:43 2016 | ||
************************************************************************/ | ||
|
||
#include <stdio.h> | ||
#include <math.h> | ||
|
||
int main() | ||
{ | ||
int i, j, k, n; | ||
for(i=2; i<=100; i++) | ||
{ | ||
k=(int)sqrt(i); | ||
for(j=2; j<=k; j++) | ||
if(i%j==0) | ||
break; | ||
if(j>k) | ||
{ | ||
printf("%-d ",i); | ||
n++; | ||
if(n%5==0) | ||
printf("\n"); | ||
} | ||
} | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/************************************************************************* | ||
> File Name: 1-37.c | ||
> Author: Tony | ||
> Mail: shouqitao@163.com | ||
> Created Time: Wed Sep 14 23:25:54 2016 | ||
************************************************************************/ | ||
|
||
#include <stdio.h> | ||
#define N 10 | ||
|
||
int main() | ||
{ | ||
int i, j, a[N], temp; | ||
printf("Please input 10 integers: \n"); | ||
for(i=0; i<N; i++) | ||
scanf("%d",&a[i]); | ||
for(i=0; i<N-1; i++) | ||
{ | ||
int min = i; | ||
for(j=i+1; j<N; j++) | ||
if(a[min]>a[j]) | ||
min=j; | ||
if(min!=i) | ||
{ | ||
temp=a[min]; | ||
a[min]=a[i]; | ||
a[i]=temp; | ||
} | ||
} | ||
printf("The sorted lsit is :\n"); | ||
for(i=0; i<N; i++) | ||
printf("%d ",a[i]); | ||
printf("\n"); | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/************************************************************************* | ||
> File Name: 1-38.c | ||
> Author: Tony | ||
> Mail: shouqitao@163.com | ||
> Created Time: Wed Sep 14 23:34:57 2016 | ||
************************************************************************/ | ||
|
||
#include <stdio.h> | ||
#define N 3 | ||
|
||
int main() | ||
{ | ||
int i, j, a[N][N], sum=0; | ||
printf("Please intput the matrix(3*3)\n"); | ||
for(i=0; i<N; i++) | ||
for(j=0; j<N; j++) | ||
scanf("%d",&a[i][j]); | ||
for(i=0;i<N;i++) | ||
sum+=a[i][i]; | ||
printf("the corner line sum is :%d\n",sum); | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/************************************************************************* | ||
> File Name: 1-39.c | ||
> Author: Tony | ||
> Mail: shouqitao@163.com | ||
> Created Time: Wed Sep 14 23:43:35 2016 | ||
************************************************************************/ | ||
|
||
#include <stdio.h> | ||
|
||
int main() | ||
{ | ||
int a[11] = {1, 4, 6, 9, 13, 16, 19, 28, 40, 100}; | ||
int temp1, temp2, number, end, i, j; | ||
printf("the old array is \n"); | ||
for(i = 0; i < 10; i++) | ||
printf("%4d", a[i]); | ||
printf("\nthe new array is "); | ||
scanf("%d", &number); | ||
end = a[9]; | ||
if(number > end) | ||
a[10] = number; | ||
else | ||
{ | ||
for(i = 0; i < 10; i++) | ||
{ | ||
if(a[i] > number) | ||
{ | ||
temp1 = a[i]; | ||
a[i] = number; | ||
|
||
for(j = i = 1; j < 11; j++) | ||
{ | ||
temp2 = a[j]; | ||
a[j] = temp1; | ||
temp1 = temp2; | ||
} | ||
break; | ||
} | ||
} | ||
} | ||
for(i = 0; i < 11; i++) | ||
printf("%4d", a[i]); | ||
printf("\n"); | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <stdio.h> | ||
#define N 10 | ||
|
||
int main() | ||
{ | ||
int a[N]={0,1,2,3,4,5,6,7,8,9}; | ||
int i,t; | ||
printf("the old array is :\n"); | ||
for(i=0;i<N;i++) | ||
printf("%d ",a[i]); | ||
for(i=0;i<N/2;i++) | ||
{ | ||
t=a[i]; | ||
a[i]=a[N-1-i]; | ||
a[N-1-i]=t; | ||
} | ||
|
||
printf("\nthe new array is :\n"); | ||
for(i=0;i<N;i++) | ||
printf("%d ",a[i]); | ||
printf("\n"); | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <stdio.h> | ||
int main() | ||
{ | ||
void fun(); | ||
for(int i = 0; i < 3; i++) | ||
fun(); | ||
return 0; | ||
} | ||
|
||
void fun() | ||
{ | ||
int i = 0; | ||
static int static_i = 0; | ||
printf("i=%d\n", i); | ||
printf("static_i=%d\n", static_i); | ||
i++; | ||
static_i++; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <stdio.h> | ||
int main() | ||
{ | ||
int i, num; | ||
num = 2; | ||
for(i = 0; i < 3; i++) | ||
{ | ||
printf("num 变量为 %d \n", num); | ||
num++; | ||
{ | ||
auto int num = 1; | ||
printf("内置模块 num 变量为 %d \n", num); | ||
num++; | ||
} | ||
} | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <stdio.h> | ||
|
||
int main() | ||
{ | ||
int i, num; | ||
num=2; | ||
for(i=0;i<3;i++) | ||
{ | ||
printf("the num is: %d\n",num); | ||
num++; | ||
{ | ||
static int num=1; | ||
printf("the inner num is: %d\n",num); | ||
num++; | ||
} | ||
} | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <stdio.h> | ||
|
||
int a,b,c; | ||
void add() | ||
{ | ||
int a; | ||
a=3; | ||
c=a+b; | ||
} | ||
|
||
int main() | ||
{ | ||
a=b=4; | ||
add(); | ||
printf("C's value is: %d\n",c); | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include <stdio.h> | ||
|
||
int main() | ||
{ | ||
register int i; | ||
int tmp=0; | ||
for(i=0;i<=100;i++) | ||
tmp+=i; | ||
printf("Sum is %d\n", tmp); | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <stdio.h> | ||
#define TRUE 1 | ||
#define FALSE 0 | ||
#define SQ(x) (x)*(x) | ||
|
||
int main() | ||
{ | ||
int num; | ||
int again = 1; | ||
printf("if num less than 50 the program will stop. \n"); | ||
while (again) | ||
{ | ||
printf("\nPlease input a number: "); | ||
scanf("%d", &num); | ||
printf("the value of num*num is %d \n", SQ(num)); | ||
if (num >= 50) | ||
again = TRUE; | ||
else | ||
again = FALSE; | ||
} | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include <stdio.h> | ||
#define exchange(a,b){int t;t=a;a=b;b=t;} | ||
|
||
int main() | ||
{ | ||
int x = 10; | ||
int y = 20; | ||
printf("x=%d; y=%d\n", x, y); | ||
exchange(x, y); | ||
printf("x=%d; y=%d\n", x, y); | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <stdio.h> | ||
#define SMA < | ||
#define LAG > | ||
#define EQ == | ||
|
||
int main() | ||
{ | ||
int i, j; | ||
printf("Please input two integers: \n"); | ||
scanf("%d %d", &i, &j); | ||
if(i LAG j) | ||
printf("%d is greater then %d \n", i, j); | ||
else if(i EQ j) | ||
printf("%d is equal %d \n", i, j); | ||
else if( i SMA j) | ||
printf("%d is less the %d \n", i, j); | ||
return 0; | ||
} |
Binary file not shown.
Oops, something went wrong.