HDU1020

来源:互联网 发布:暴风影音官网windows版 编辑:程序博客网 时间:2024/05/17 21:39
用这种方法实现的代码好像在哪看过,但忘记了在哪了
/*vector_change----HDU1020*/#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#define N 1010#define LL long long#define debug(x) cout<<#x<<":"<<(x)<<endl;using namespace std;//15-2-5int main(){    int n;    scanf("%d", &n);    char ch1, ch2;    int num = 1;    getchar(); //吸收按回车    while( n-- )    {        ch1 = getchar();        while( ch2 != '\n' ) //结束条件,遇到回车键        {            ch2 = getchar();            if( ch2 == ch1 ) num++;            else{                if(num>1) printf("%d%c", num, ch1);                else printf("%c", ch1);                num = 1;            }            ch1 = ch2;        }        ch2 = '0';  //ch2 会留下上次的'\n'所以要清空        printf("\n");    }    return 0;}

0 0
原创粉丝点击