源程序:
#include < iostream >
using namespace std;
char up(char c)
{
if (c >= 'a' && c <= 'z')
return (c - 32); //大小写字母的ASCII相差32
else
return c;
}
void main()
{
int i;
char c[15] = { 'A','v','e','t','E','T','%','&','4','Y','e','i','@','9','^' };
for (i = 0; i < 15; i++)
cout << up(c[i]) << ", ";
cout << endl;
system("pause");
}
运行结果: