zoukankan      html  css  js  c++  java
  • 字符串-03. 字符串的冒泡排序

    字符串-02. 删除字符串中的子串(20)

    时间限制
    400 ms
    内存限制
    65536 kB
    代码长度限制
    8000 B
    判题程序
    Standard
    作者
    白洪欢(浙江大学)

    输入2个字符串S1和S2,要求删除字符串S1中出现的所有子串S2,即结果字符串中不能包含S2。

    输入格式:

    输入在2行中分别给出不超过80个字符长度的、以回车结束的2个非空字符串,对应S1和S2。

    输出格式:

    在一行中输出删除字符串S1中出现的所有子串S2后的结果字符串。

    输入样例:
    Tomcat is a male ccatat
    cat
    
    输出样例:
    Tom is a male
     1 #include<stdio.h>
     2 #include<math.h>
     3 #include<stdlib.h>
     4 #include<string.h>
     5 int main()
     6 {
     7     char str[110][15], temp[15];
     8     int i, j, n, k;
     9     scanf("%d%d", &n, &k);
    10     getchar();
    11     for(i = 0; i < n; i++)
    12         gets(str[i]);
    13     for(i = 1; i <= k ; i++)
    14         for(j = 0; j < n - i; j++)
    15         {
    16             if(strcmp(str[j], str[j+1]) > 0)
    17             {
    18                 strcpy(temp, str[j]);
    19                 strcpy(str[j], str[j+1]);
    20                 strcpy(str[j+1], temp);
    21             }
    22         }
    23     for(i = 0; i < n; i++)
    24         printf("%s
    ", str[i]);
    25     return 0;
    26 }
  • 相关阅读:
    centos 安装docker-ce
    quartz.net .netcore 定时任务部署到linux
    c# 获取linux 磁盘信息
    nginx 安装
    async await 理解
    Remote side unexpectedly closed network connection
    centos 安装。net
    yum 操作
    centos7下安装mysql5.7
    git 本地仓库版本无法从远程更新到本地
  • 原文地址:https://www.cnblogs.com/yomman/p/4240304.html
Copyright © 2011-2022 走看看