2009-10-02 22:43:40來源不明

2.字串處理

作法 : 模擬

這題應該是UVA  好像有看過...

/*********************************************************/

#include<stdlib.h>
#include<stdio.h>
#include<string.h>
main()
{
   char s[1000];
   while(gets(s))
      {
          int n=strlen(s),temp=0;
          int a,b,c;
          for(a=0;a<n;a++)
             if(s[a]<=57&&s[a]>=48) temp+=s[a]-48;
             else
             {
                if(s[a]!='b'&&s[a]!='!')
                for(b=0;b<temp;b++)
                   printf("%c",s[a]);
                else if(s[a]=='b')
                for(b=0;b<temp;b++)
                   printf(" "); 
                else
                   printf("\n");
                temp=0;
             }
          printf("\n");
      }
   return 0;
}

上一篇:很大的質數判斷

下一篇:一棵小樹