主题:enum 的问题 高手看看帮帮忙 先谢谢了
#include <iostream.h>
#include <conio.h>
#include <string.h>
char *upper(char s[],Option u)
{
int m = 1;
int t='a'-'A';
int n=strlen(s);
if (s[0]>='a'&&s[0]<='z')
s[0]-=t;
if (u==All)
{
for (m=1;m<=n;m++)
{
if(s[m]!='\0'&&(s[m]>='a'&&s[m]<='z'))
{
s[m]-=t;
}
}
}
if (u == Head)
{
for (m=1;m<=n;m++)
{
if (s[m]=='.' || s[m]=='?' || s[m]=='!')
{
if (s[m+1]!='\0')
{
s[m+1]-=t;
}
}
}
}
if (u == Whead)
{
for (m=1;m<=n;m++)
{
if ( s[m]=='.' || s[m]=='?' || s[m]=='!'|| s[m] == ' ' ||
s[m] == ','|| s[m] == ':' )
{
if (s[m+1]!='\0')
{
s[m+1]-=t;
}
}
}
}
return s;
}
void main()
{
enum Option
{All,Head,Whead} a,b,c;
a=All;
b=Head;
c=Whead;
char a[100]="ming tian shi wo men de jie ri,wei shen me ne?ni bu xing." ;
cout<<upper(a[100],a)<<endl;
cout<<upper(a[100],b)<<endl;
cout<<upper(a[100],c)<<endl;
getch();
}
#include <conio.h>
#include <string.h>
char *upper(char s[],Option u)
{
int m = 1;
int t='a'-'A';
int n=strlen(s);
if (s[0]>='a'&&s[0]<='z')
s[0]-=t;
if (u==All)
{
for (m=1;m<=n;m++)
{
if(s[m]!='\0'&&(s[m]>='a'&&s[m]<='z'))
{
s[m]-=t;
}
}
}
if (u == Head)
{
for (m=1;m<=n;m++)
{
if (s[m]=='.' || s[m]=='?' || s[m]=='!')
{
if (s[m+1]!='\0')
{
s[m+1]-=t;
}
}
}
}
if (u == Whead)
{
for (m=1;m<=n;m++)
{
if ( s[m]=='.' || s[m]=='?' || s[m]=='!'|| s[m] == ' ' ||
s[m] == ','|| s[m] == ':' )
{
if (s[m+1]!='\0')
{
s[m+1]-=t;
}
}
}
}
return s;
}
void main()
{
enum Option
{All,Head,Whead} a,b,c;
a=All;
b=Head;
c=Whead;
char a[100]="ming tian shi wo men de jie ri,wei shen me ne?ni bu xing." ;
cout<<upper(a[100],a)<<endl;
cout<<upper(a[100],b)<<endl;
cout<<upper(a[100],c)<<endl;
getch();
}