Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
看来只能做做水题度日了...题目看着一句就行:For example, the string 122344111 can be described as "one 1, two 2's, one 3, two 4's, three 1's". #include<cstdio> char a[1005]; int i, s, k,t; int main() { scanf("%d", &t); while (t--&&scanf("%s", a)) { k = 0, i = 1; while (a[++k]) if (a[k] == a[k - 1]) i++; else printf("%d%c", i, a[k - 1]), i = 1; printf("%d%c\n", i, a[k - 1]); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator