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();
            }
        }
    }
  • 相关阅读:
    USART串口通信实验
    EXTI 外部中断
    NVIC中断优先级管理
    实验1 跑马灯实验
    redis集群部署---一台主机
    zookeeper服务启动报错---Error contacting service. It is probably not running.
    shell脚本学习笔记
    最短路径算法——Floyd算法
    一篇文章学懂Shell脚本(摘抄)
    VIM空格和TAB转换
  • 原文地址:https://www.cnblogs.com/Wzqa/p/2790210.html
Copyright © 2011-2022 走看看