zoukankan      html  css  js  c++  java
  • 53字符逐位比较大小

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace _5_3
    {
        class Program
        {
            static void Main(string[] args)
            {
                string strA, strB;
                int i;
                bool bA;
                i = 0;
                bA = true;
    
                Console.WriteLine("请输入字符串1:");
                strA = Console.ReadLine();
                Console.WriteLine("请输入字符串2:");
                strB = Console.ReadLine();
    
                Console.WriteLine("----------------------------------------");
                while (i < strA.Length && i < strB.Length)
                {
    
                    if (strA[i] > strB[i])
                    {
                        Console.WriteLine("字符串{0} 大于 字符串{1}", strA, strB);
                        Console.WriteLine("----------------------------------------");
                        Console.ReadKey();
                        return;
    
                    }
                    if (strA[i] < strB[i])
                    {
                        Console.WriteLine("字符串{0} 小于 字符串{1}", strA, strB);
                        Console.WriteLine("----------------------------------------");
                        Console.ReadKey();
                        return;
                    }
    
                    i++;
    
                }
    
                if (i < strB.Length)
                {
                    Console.WriteLine("字符串{0} 小于 字符串{1}", strA, strB);
                    Console.WriteLine("----------------------------------------");
                    Console.ReadKey();
                    return;
                }
                if (i < strA.Length)
                {
                    Console.WriteLine("字符串{0} 大于 字符串{1}", strA, strB);
                    Console.WriteLine("----------------------------------------");
                    Console.ReadKey();
                    return;
                }
    
                Console.WriteLine("字符串{0} 等于 字符串{1}", strA, strB);
    
    
                Console.WriteLine("----------------------------------------");
                Console.ReadKey();
            }
        }
    }
  • 相关阅读:
    POJ3264 线段树模板
    Dijkstra算法模板 C++
    POJ 1287 Prim算法模板
    ZOJ 2107 Quoit Design(分治法解最近对模板题)
    POJ 3714 Raid 分治法求最近对问题
    最长上升子序列(LIS)及其优化O(nlongn)
    PAT1146 Topological Order
    PAT甲级 _A+B Format
    PAT乙级_A+B与C
    PAT乙级_继续3n+1猜想
  • 原文地址:https://www.cnblogs.com/Wzqa/p/2790210.html
Copyright © 2011-2022 走看看