输入:字符串A
操作:将字符串A中的大写字母转换成小写字母(非A-Z删除,小写不变)
输出: 转换后的字符串B
#include <stdlib.h>
#include "oj.h"
#include <string.h>
/*
功能:将输入的字符串中英文大写字母改成对应小写字母,并且过滤掉非英文字母字符
输入:字符串
输出:结果字符串,保证输出地址有效。
返回:0表示成功,其它返回-1
*/
int ProcessString(char * strInput,char *strOutput)
{
if ( NULL == strInput || NULL == strOutput)
{
return -1;
}
while (*strInput !='\0') {
if ((*strInput >='A')&&(*strInput <= 'Z') ) {
*strOutput = *strInput + 'a' - 'A';
strInput++; strOutput++;
}
else if ((*strInput >= 'a') && (*strInput <= 'z')) {
*strOutput = *strInput;
strInput++; strOutput++;
}
else {
strInput++;
}
}
*strOutput = '\0';
return 0;
}