#include<stdio.h>
#if 0
void main()
{
void average(float *p,int n);
void search(float (*p)[4],int n);
float a[3][4] = {65,67,70,60,80,87,90,81,90,99,100,98};
average(*a,12);
search(a,2);
}
void average(float *p,int n)
{
float *end = p+n;
float sum = 0,ave;
for(;p<end;p++)
sum += *p;
ave = sum/n;
printf("%.2f/n",ave);
}
void search(float (*p)[4],int n)
{
int i;
for(i = 0;i<4;i++)
printf("%-7.2f",*(*(p+2)+i));
printf("/n");
}
#endif
#if 0
void main()
{
void search(float (*p)[4],int n);
float a[3][4] = {65,57,70,60,58,87,90,81,90,99,100,98};
search(a,3);
}
void search(float (*p)[4],int n)
{
int i,j,flag;
for(j = 0;j<n;j++)
{
flag = 0;
for(i = 0;i<4;i++)
if(*(*(p+j)+i) < 60)
flag = 1;
if(flag == 1)
{
for(i = 0;i<4;i++)
printf("%-7.2f",*(*(p+j)+i));
printf("/n");
}
}
}
#endif
#if 0
void main()
{
//char s[20] = "Hello world!";
//char *str;
//str = s;
//char *str;
//str = "Hello world!";
char *str = "Hello world!";
puts(str);
}
#endif
#if 0
//copy
void main()
{
char a[] = "Hello world!";
char b[20];
int i;
for(i = 0;*(a+i) != '/0';i++)
*(b+i) = *(a+i);
*(b + i) = '/0';
printf("String a :%s/n",a);
printf("String b :%s/n",b);
}
#endif
#if 0
//copy 用指针变量
void main()
{
char a[] = "Hello world!";
char b[20];
char *p,*q;
p = a;
q = b;
for(;*p != '/0';p++,q++)
*q = *p;
*q = '/0';
printf("String a :%s/n",a);
printf("String b :%s/n",b);
}
#endif
#if 0
void main()
{
void copy(char s1[],char s2[]);
char a[] = "I am a teacher .";
char b[] = "You are a student .";
printf("string a :%s/nstring b :%s/n",a,b);
printf("copy a to b ./n");
copy(a,b);
printf("string a :%s/nstring b :%s/n",a,b);
}
void copy(char s1[],char s2[])
{
int i = 0;
for(;s1[i]!='/0';i++)
s2[i] = s1[i];
s2[i] = '/0';
}
#endif
#if 0
void main()
{
void copy(char s1[],char s2[]);
char *a = "I am a teacher .";
char *b = "You are a student .";
printf("string a :%s/nstring b :%s/n",a,b);
printf("copy a to b ./n");
copy(a,b);
printf("string a :%s/nstring b :%s/n",a,b);
}
void copy(char s1[],char s2[])
{
int i = 0;
for(;s1[i]!='/0';i++)
s2[i] = s1[i];
s2[i] = '/0';
}
#endif
#if 0
void main()
{
void copy(char *s1,char *s2);
char a[] = "I am a teacher .";
char b[] = "You are a student .";
printf("string a :%s/nstring b :%s/n",a,b);
printf("copy a to b ./n");
copy(a,b);
printf("string a :%s/nstring b :%s/n",a,b);
}
void copy(char *s1,char *s2)
{
for(;*s1!='/0';s1++,s2++)
*s2 = *s1;
*s2 = '/0';
}
#endif
#if 0
void main()
{
int n=10;
int a[10][10];
int i,j;
for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
{
if(j==0||j==i)
{
a[i][j]=1;
}
else
a[i][j]=a[i-1][j-1]+a[i-1][j];
printf("%d/t",a[i][j]);
}
printf("/n");
}
}
#endif
#if 0
void main()
{
int a = 1,b = 9;
char *format = "a = %d,b = %d/n";
printf(format,a,b);
}
#endif
#if 0
void main()
{
int max(int a,int b);
int (*p)(int,int);//指向函数的指针
int a,b,c;
p = max;//函数的入口地址给指针变量
scanf("%d%d",&a,&b);
c = (*p)(a,b);//调用函数
printf("max = %d/n",c);
}
int max(int a,int b)
{
return (a>b?a:b);
}
#endif
#if 0
void main()
{
int max(int,int);
int min(int,int);
int add(int,int);
void process(int,int,int (*funtion)(int,int));
int a,b;
scanf("%d%d",&a,&b);
printf("max = ");
process(a,b,max);
printf("min = ");
process(a,b,min);
printf("sum = ");
process(a,b,add);
}
int max(int a,int b)
{
return (a>b?a:b);
}
int min(int a,int b)
{
return (a<b?a:b);
}
int add(int a,int b)
{
return (a+b);
}
void process(int a,int b,int (*funtion)(int,int))
{
int result;
result = (*funtion)(a,b);
printf("%d/n",result);
}
#endif