华为oj---小写转换

输入:字符串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;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值