zoukankan      html  css  js  c++  java
  • 将两个字符串中相同的地方str2无重复的输出

    str1 = "abcdefghijklmnopq";

    str2 = "goodgoodxyz";

    最简单的做法:

     public static string str1 = "abcdefghigklmnopqg",

    str2 = "goodgoodxyz";

            public static int i, j,temp=0;

            static void Main(string[] args)

            {

                for(i=0;i<str2.Length;i++)//外边放str2

                {

                    for(j=0;j<str1.Length;j++)

                    {

                       

                        if (str2[i] == str1[j])

                        {

                            Console.Write(str2[i]);

                            break;//关键算法

                        }

                    }

                }

                Console.ReadKey();

            }

     

  • 相关阅读:
    用户登录
    open >>>文件操作
    随机数
    内置函数
    函数练习
    函数的动态参数
    函数的指定参数
    函数的普通参数
    函数的初步认识
    copy
  • 原文地址:https://www.cnblogs.com/duoduo0605/p/2779122.html
Copyright © 2011-2022 走看看