POJ 3438 Look and Say

来源:互联网 发布:adobe音乐编辑软件 编辑:程序博客网 时间:2024/05/21 09:00
//============================================================================
// Name        : hello.cpp
// Author      : key
// Version     : ∞
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================



#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;


//POJ 3438

char str[1010];
int main()
{
    int temp;
    char *p;
    char pre;
    int t;
    scanf("%d",&t);
    while(t--&&scanf("%s",str)!=EOF)
    {
        pre = '0';
        p=str;
        temp = 0;
        while(1)
        {
            if(*p != pre)
            {
                if(temp!=0)
                    printf("%d%c",temp,pre);
                pre = *p;
                temp = 1;
            }
            else
                temp++;
            if(!(*p))
                break;
            p++;
        }
        printf("\n");
    }
    return 0;
}