(1)实现小写字母变为大写字母
#include<stdio.h>
#include<string.h>
int main()
{
char a[20]="a2b4cd58eF9G";
int i;
char *p;
p=a;
const char delta='A'-'a';
for(i=0;i<strlen(a);i++)
{
if(a[i]>='a' && a[i]<='z')
{
p[i]=a[i]+delta;
}
else
{
p[i]=a[i];
}
}
p[i] = '\0';
puts(p);
}
(2)实现大写字母变为小写字母
#include<string.h>
#include<stdio.h>
int main()
{
char a[20]="a2b4cd58eF9G";
int i;
char *p;
p=a;
const char delta='a'-'A';
for(i=0;i<strlen(a);i++)
{
if(a[i]>='A' && a[i]<='Z')
{
p[i]=a[i]+delta;
}
else
{
p[i]=a[i];
}
}
p[i] = '\0';
puts(p);
}
#include<stdio.h>
#include<string.h>
int main()
{
char a[20]="a2b4cd58eF9G";
int i;
char *p;
p=a;
const char delta='A'-'a';
for(i=0;i<strlen(a);i++)
{
if(a[i]>='a' && a[i]<='z')
{
p[i]=a[i]+delta;
}
else
{
p[i]=a[i];
}
}
p[i] = '\0';
puts(p);
}
(2)实现大写字母变为小写字母
#include<string.h>
#include<stdio.h>
int main()
{
char a[20]="a2b4cd58eF9G";
int i;
char *p;
p=a;
const char delta='a'-'A';
for(i=0;i<strlen(a);i++)
{
if(a[i]>='A' && a[i]<='Z')
{
p[i]=a[i]+delta;
}
else
{
p[i]=a[i];
}
}
p[i] = '\0';
puts(p);
}