• 【ACM】poj_3981_字符串替换_201307271019


    字符串替换
    Time Limit: 1000MS  Memory Limit: 65536K
    Total Submissions: 8447  Accepted: 3988

    Description

    编写一个C程序实现将字符串中的所有"you"替换成"we"
    Input

    输入包含多行数据

    每行数据是一个字符串,长度不超过1000
    数据以EOF结束
    Output

    对于输入的每一行,输出替换后的字符串
    Sample Input

    you are what you do
    Sample Output

    we are what we do

    #include <stdio.h>
    #include <string.h>
    int main()
    {
     char str[1010];
     while(gets(str))
     {
      int i;
      for(i=0;i<strlen(str);i++)
      {
       if(str[i]=='y'&&str[i+1]=='o'&&str[i+2]=='u')
       {
        printf("we");
        i+=2;
       }
       else
       printf("%c",str[i]);
      }
      printf(" ");
     }
     return 0;
    }

  • 相关阅读:
    Html5结构相关元素
    html5文本元素
    html5全局属性
    元数据元素总结
    千里之行,始于足下
    换个角度思考
    java的权限修饰符
    四则运算
    测量软件使用感受
    JQuery高级
  • 原文地址:https://www.cnblogs.com/xl1027515989/p/3219120.html
Copyright © 2020-2023  润新知