#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
void math_lower(char* str)
{
while (*str != '\0')
{
if (*str >= 64 && *str <= 90)
*str = *str + 32;
str++;
}
}
void math_higher(char* str)
{
while (*str != '\0')
{
if (*str >= 97 && *str <= 122)
*str = *str - 32;
str++;
}
}
//ASCII码大写字母转小写
//大写字母64~~~90(首尾都包含)
//小写字母97~~~122(首尾都包含)
void lib_lower(char* str)
{
while (*str != '\0')
{
*str = (char)tolower((int)(*str));
str++;
}
}
int main()
{
#define ARRAY 27
char s[ARRAY];
memset(s, 0, ARRAY);
srand(time(NULL));
for (int i = 0; i < ARRAY-1; i++)
{
RE:
int tmp = rand() % 91;
if (tmp < 65)
goto RE;
s[i] = tmp;
}
s[ARRAY - 1] = '\0';
printf("原 始 数 据:%s\n",s);
math_lower(s);
printf("math__lower:%s\n",s);
math_higher(s);
printf("math_higher:%s\n", s);
lib_lower(s);
printf("lib___lower:%s\n", s);
return 0;
}