Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

高手帮我看看呀,实在不知道错在哪里,测试数据都准确

Posted by westboy at 2006-05-07 01:59:35 on Problem 1782
#include <stdio.h>
#include <string.h>
int main(){
	char buf[10000];
	int i,j,length,count=1,albe=0;
	while(gets(buf)!=NULL){
		length=strlen(buf);
		for(i=0,j=1;i<length;i++,j++){
			if(buf[i]==buf[j]){
				count++;
				if(count>9){
					printf("9%c",buf[i]);
					count=count-9;
				}
				if(albe==1){
					printf("1");
					albe=0;
				}
			}
			else{
				if(count==1){
					if(albe==0) {
						printf("1");
						albe=1;
					}
					if(buf[i]=='1')
						printf("%s","11");
					else
						printf("%c",buf[i]);
				}
				else if(count>1){
					printf("%d%c",count,buf[i]);
					count=1;
				}
			}

		}
		if(albe==1){
			albe=0;
			printf("1");
		}
		printf("%\n");
		
	}
	return 1;
}


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator