zoukankan      html  css  js  c++  java
  • 考前复习记录

    字符串读入直接读字符数组

    char s[1004];
    scanf("%s",s);

    但是要用strlen(s)来算长度 复杂度O(n)

    e.g.a串是不是b的子串

    //从a第0位开始枚举
    //如果a的第0位=b的第i位
    //就从b的第i位开始枚举检查

    #include<cstdio>
    #include<iostream>
    #include<cmath>
    #include<cstring>
    #include<queue>
    #include<vector>
    #define maxn 1000005
    using namespace std;
    char a[maxn],b[maxn];
    int main()
    {
        scanf("%s%s",a,b);
        int na=strlen(a),nb=strlen(b);
        for(int i=0;i<nb;i++)
        {
            if(b[i]==a[0])
            {
                bool te=0;
                for(int j=0;j<na;j++)
                {
                    if(i+j-1<nb)
                    {
                        if(b[i+j]!=a[j]){te=1;break;}
                    }
                }
                if(te==0)printf("%d
    ",i);
            }
        }
        return 0;
    }
    View Code

    背包问题

    http://www.cnblogs.com/gc812/p/5791276.html


    spfa

    http://www.cnblogs.com/gc812/p/5808132.html


    拓扑排序

    http://www.cnblogs.com/gc812/p/7786571.html


    奇怪的东西

    http://www.cnblogs.com/gc812/p/7811239.html


     奇怪的练习

    http://www.cnblogs.com/gc812/p/6034907.html


  • 相关阅读:
    《一起》Alpha版软件使用说明
    意见评论
    评论总结
    项目评审
    对大神联盟博客的检查结果
    SmartCoder每日站立会议10
    SmartCoder每日站立会议09
    mac php环境启动
    gulp工具rename
    gulp图片压缩
  • 原文地址:https://www.cnblogs.com/gc812/p/7816083.html
Copyright © 2011-2022 走看看