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 |
贴一下代码吧,代码很短,牺牲了时间#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator