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 wzp_moon at 2015-08-12 16:05:06 on Problem 3438
#include <stdio.h>
#include <string.h>
int main(void)
{
	char a[1001];/*notice!1000的话只能存1000个数,结束符就没有地方放了,导致计算错误*/
	int i,j,k,num,n,m = 0;
	scanf("%d",&n);
	for (i = 0;i < n;i++)
	{
		scanf("%s",a);
		num = 1;
		for(j = 0;j < strlen(a);j = m)
		{
			k = j + 1;
			
			if (a[k] == a[j])
			{
				num++;
			}
			else
			{
				printf("%d%d",num,((int)a[j] - 48));
				num = 1;
			}
			m = k;
		}
		printf("\n");
	}
	return 0;
}

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