zoukankan      html  css  js  c++  java
  • ACM POJ 3981 字符串替换(简单题)

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

    Description

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

    Input

    输入包含多行数据

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

    Output

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

    Sample Input

    you are what you do

    Sample Output

    we are what we do

    Source

     

     

    #include<stdio.h>
    #include
    <string.h>
    #include
    <iostream>
    using namespace std;
    char str[1010];
    int main()
    {
    int i;
    int len;
    while(cin.getline(str,1010))
    {
    len
    =strlen(str);
    for(i=0;i<len;i++)
    {
    if(i+2<len&&str[i]=='y'&&str[i+1]=='o'&&str[i+2]=='u')
    {
    printf(
    "we");
    i
    +=2;
    continue;
    }
    printf(
    "%c",str[i]);
    }
    printf(
    "\n");
    }
    return 0;
    }
  • 相关阅读:
    日志
    mysql锁
    慢查询
    auto_increment
    脚本
    服务器元数据
    复制表及表数据
    临时表
    (一)校园信息通微信小程序从前端到后台整和笔记
    OpenCart框架运行流程介绍opencart资料链接
  • 原文地址:https://www.cnblogs.com/kuangbin/p/2178107.html
Copyright © 2011-2022 走看看