Skip to content

Commit

Permalink
addfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Player authored and Player committed Apr 14, 2017
1 parent 8c8fb4f commit f018503
Show file tree
Hide file tree
Showing 78 changed files with 1,393 additions and 12 deletions.
Binary file added .DS_Store
Binary file not shown.
6 changes: 6 additions & 0 deletions C Practice/#test.c#
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <stdio.h>
int main()
{
printf("hello world.");
return 0;
}
2 changes: 2 additions & 0 deletions C Practice/#tony.c#
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include <stdio.h>
int main( string[ ] )
Binary file modified C Practice/.vscode/.BROWSE.VC.DB
Binary file not shown.
Binary file removed C Practice/.vscode/.BROWSE.VC.DB-shm
Binary file not shown.
Binary file removed C Practice/.vscode/.BROWSE.VC.DB-wal
Binary file not shown.
Binary file added C Practice/1-33
Binary file not shown.
Binary file added C Practice/1-34
Binary file not shown.
2 changes: 1 addition & 1 deletion C Practice/1-34.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ int main(void)
{
three_hellos();
return 0;
}
}
Binary file added C Practice/1-35
Binary file not shown.
45 changes: 36 additions & 9 deletions C Practice/1-35.c
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 added C Practice/1-36
Binary file not shown.
29 changes: 29 additions & 0 deletions C Practice/1-36.c
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 added C Practice/1-37
Binary file not shown.
35 changes: 35 additions & 0 deletions C Practice/1-37.c
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 added C Practice/1-38
Binary file not shown.
22 changes: 22 additions & 0 deletions C Practice/1-38.c
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 added C Practice/1-39
Binary file not shown.
45 changes: 45 additions & 0 deletions C Practice/1-39.c
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 added C Practice/1-40
Binary file not shown.
23 changes: 23 additions & 0 deletions C Practice/1-40.c
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 added C Practice/1-41
Binary file not shown.
18 changes: 18 additions & 0 deletions C Practice/1-41.c
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 added C Practice/1-42
Binary file not shown.
17 changes: 17 additions & 0 deletions C Practice/1-42.c
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 added C Practice/1-43
Binary file not shown.
18 changes: 18 additions & 0 deletions C Practice/1-43.c
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 added C Practice/1-44
Binary file not shown.
17 changes: 17 additions & 0 deletions C Practice/1-44.c
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 added C Practice/1-45
Binary file not shown.
11 changes: 11 additions & 0 deletions C Practice/1-45.c
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 added C Practice/1-46
Binary file not shown.
22 changes: 22 additions & 0 deletions C Practice/1-46.c
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 added C Practice/1-47
Binary file not shown.
12 changes: 12 additions & 0 deletions C Practice/1-47.c
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 added C Practice/1-48
Binary file not shown.
18 changes: 18 additions & 0 deletions C Practice/1-48.c
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 added C Practice/1-49
Binary file not shown.
Loading

0 comments on commit f018503

Please sign in to comment.