现在的位置: 首页 > 综合 > 正文

华为上机第二题

2013年12月07日 ⁄ 综合 ⁄ 共 427字 ⁄ 字号 评论关闭
#include "stdafx.h"
#include <iostream>

char strnum(char *pInput,int length,char *output)
{
	if (pInput==NULL&&length<1)
		return 0;
	int count=0;
	int i=0;
	int k=0;
	
		while (pInput[i]!='\0'){
			if (pInput[i]==pInput[i+1])
				count++;
			else{
				if (count==0){
					output[k++]=1+'0';
					output[k++]=pInput[i];
										
				}
				else{
					output[k++]=count+1+'0';
					output[k++]=pInput[i];
					count=0;
				}

				}
			
			i++;
		}
		
	
	
	output[k]='\0';
	std::cout<<output<<std::endl;
}
int main()
{

	char *a="aaaayycch";
	char *b=new char;
	strnum(a,9,b);
}

抱歉!评论已关闭.