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 }
  • 相关阅读:
    nyoj 42 一笔画 欧拉通路
    布丰投针实验1
    poj 1328 贪心
    uva 10026 贪心
    zoj 1375 贪心
    uva 103 经典DAG变形
    uva 11088 暴力枚举子集/状压dp
    jsp分页功能
    static静态变量的理解
    Vector & ArrayList 的主要区别
  • 原文地址:https://www.cnblogs.com/yomman/p/4240304.html
Copyright © 2011-2022 走看看