组长我来开个头~~

先从初级题入手:

Prob 1.求int型整数中1的个数

#include <stdlib.h>
#include <string.h>
#include "oj.h"
#include<stdio.h>


/*
功能:

输入:整型

输出:
     
返回:返回1的个数
*/

int GetCount(int iValue)
{
	char bits[33];
	memset(bits, 0, sizeof(char) * 33);

	itoa(iValue, bits, 2);
//	printf("\n%s\n", bits);
	int cnt = 0;
	for (int i = 0; i < 33; i++)
	{
		if (bits[i] == '1')
		{
			cnt++;
		}
	}

	return cnt;
	return 0;
}



Prob 3.  还是一道初级题   大写字母转换成小写字母,非字母过滤

#include <stdlib.h>
#include<stdio.h>
#include "oj.h"
#include <string.h>


/*
功能:将输入的字符串中英文大写字母改成对应小写字母,并且过滤掉非英文字母字符
    
输入:字符串
    
输出:结果字符串,保证输出地址有效。
     
返回:0表示成功,其它返回-1
     
*/

int  ProcessString(char * strInput,char *strOutput)
{
	if (NULL == strOutput) {
		return -1;
	}

	int i = 0;
	int j = 0;

	while (strInput[i] != '\0')
	{
		if (strInput[i] >= 'A' && strInput[i] <= 'Z')
		{
			strOutput[j] = strInput[i]-'A'+'a';
	//		printf("%c\n", strOutput[j]);
			j++;
		}
		else if (strInput[i] >= 'a' && strInput[i] <= 'z')
		{
			strOutput[j++] = strInput[i];
		}
		i++;
	}
	strOutput[j] = '\0';
	
	return 0;
}



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值