nefu 903 字符串去星

字符串去星

Problem : 903

Time Limit : 1000ms

Memory Limit : 65536K

description

有一个字符串(长度小于100),要统计其中有多少个*,并输出该字符串去掉*后的新字符串。

input

输入数据有多组,每组1个连续的字符串;

output

在1行内输出该串内有多少个* 和去掉*后的新串。

sample_input

Goodggod223**df2*w
Qqqq*

sample_output

3 Goodggod223df2w
1 Qqqq

 

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    char a[120];
    int i,j,n;
    while(scanf("%s",a)!=-1)
    {
        n=0;j=0;
        for(i=0;i<strlen(a);i++)
        {
            if(a[i]=='*')
            n++;
        }
        for(i=0,j=0;i<strlen(a);i++)
        if(a[i]!='*')
        {
            a[j]=a[i];
            j++;
        }
        a[j]='\0';
        printf("%d ",n);
        puts(a);
    }
    return 0;
}

 

posted @ 2015-11-29 11:04  邻家那小孩儿  阅读(142)  评论(0编辑  收藏  举报