// 101.c
#include<stdio.h>
void fun(char a[],char b[])
{
while(*a)a++;
while(*b)*a++=*b++;
}
void main()
{
char a[20]="china",b[]="qiyang";
fun(a,b);
puts(a);
getch();
}
// 102.c
#include<stdio.h>
#include<string.h>
void main()
{
char a[20],b[]="thisisabook";
strcpy(a,b);
puts(a);
getch();
}
// 103.c
#include<stdio.h>
void cpyfun(char a[],char b[])
{
//while(*b)*a++=*b++;
//*a=0;
int i;
for(i=0;b[i];i++)
a[i]=b[i];
a[i]=0;
}
void main()
{
char a[20],b[]="this\0isabook";
cpyfun(a,b);
puts(a);
getch();
}
// 104.c
#include<stdio.h>
#include<string.h>
int cmpfun(char a[],char b[])
{
int i=0;
while(a[i]==b[i]&&a[i]&&b[i])i++;
return a[i]-b[i];
}
void main()
{
printf("%d",cmpfun("chinab","china"));
getch();
}
// 105.c
#include<stdio.h>
#include<string.h>
int cmpfun(char a[],char b[])
{
while(*a==*b&&*a&&*b){a++;b++;}
return *a-*b;
}
void main()
{
printf("%d",cmpfun("china","chinb"));
getch();
}
// 106.c
#include<stdio.h>
#include<string.h>
int cmpfun(char a[],char b[])
{
if(*a==0&&*b==0)return 0;
if(*a!=*b)return *a-*b;
return cmpfun(a+1,b+1);
}
void main()
{
printf("%d",cmpfun("china","chinb"));
getch();
}
// 107.c
#include<stdio.h>
#include<string.h>
void main()
{
char a[]="HuNanQiYang";//驼峰式写法
strupr(a);
puts(a);
getch();
}
// 108.c
#include<stdio.h>
void uprfun(char a[])
{
int i=0;
while(a[i])
{
if(a[i]>='a'&&a[i]<='z')a[i]=a[i]-32;
i++;
}
}
void main()
{
char a[]="HuNanQiYang";//驼峰式写法
uprfun(a);
puts(a);
getch();
}
// 109.c
#include<stdio.h>
void uprfun(char a[])
{
while(*a)
{
if(*a>='a'&&*a<='z')*a=*a-32;
a++;
}
}
void main()
{
char a[]="HuNanQiYang";//驼峰式写法
uprfun(a);
puts(a);
getch();
}
// 110.c
#include<stdio.h>
void uprfun(char a[])
{
if(*a==0)return;
if(*a>='a'&&*a<='z')*a=*a-32;
return uprfun(a+1);
}
void main()
{
char a[]="HuNanQiYang";//驼峰式写法
uprfun(a);
puts(a);
getch();
}
网友评论