//将原文中的'I'替换成'U'
#include<stdio.h>
#include<string.h>
int main()
{
char a[200];
int i;
printf("Please input character: ");
gets(a);
puts(a);
printf("Replace 'I' with 'U' \n");
for(i=0;i<200;i++)
{
if(a[i]=='I')a[i]='U';
}
puts(a);
}
//统计各字符个数
#include<stdio.h>
#include<string.h>
int main()
{
int i,j=0,k=0,t=0,n=0;
char a[255];
printf("Plesae input which character you want search");
gets(a);
for(i=0;i<255;i++)
{
if(a[i]>='a'&&a[i]<='z')j++;
else if(a[i]>='A'&&a[i]<='Z')k++;
else if(a[i]>='0'&&a[i]<='9')t++;
else n++;
}
puts(a);
printf("数字:%d\n 小写字母:%d\n 大写字母:%d\n 其他:%d",j,k,t,n);
}
//大小写字母转换
#include<stdio.h>
#include<string.h>
int main()
{
char a[100],b[100];
int i;
printf("Please input character:");
gets(a);
for(i=0;i<100;i++)
{
if(a[i]>='a'&&a[i]<='z')
{
b[i]=a[i]-32;
}
else if(a[i]>='A'&&a[i]<='Z')
{
b[i]=a[i]+32;
}
else b[i]=a[i];
}
puts(a);
puts(b);
}