Advertisement
Guest User

Biz

a guest
Jan 17th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.47 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace Stringekz
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.  
  13.             int n;
  14.             Console.WriteLine("Введите кол-во строк");
  15.             n = Convert.ToInt32(Console.ReadLine());
  16.  
  17.             string[]A = new string[n];
  18.             int[] B = new int[n];
  19.             Console.WriteLine("Введите строки");
  20.  
  21.            
  22.  
  23.             for (int i = 0; i < n; i++)
  24.                 A[i] = Console.ReadLine();
  25.  
  26.            
  27.             for( int i = 0; i<n; i++)
  28.             {      
  29.                 string[]At = A[i].Split(' ');
  30.                 B[i] = At.Length;
  31.            
  32.             }
  33.  
  34.             string tmp;
  35.  
  36.             for (int i = 0; i < n; i++)
  37.             {
  38.                 for (int j = i + 1; j < n; j++)
  39.                 {
  40.                     if (B[i] > B[j])
  41.                     {
  42.                         tmp = A[i];
  43.                         A[i] = A[j];
  44.                         A[j] = tmp;
  45.                    
  46.                    
  47.                     }
  48.                
  49.                
  50.                 }
  51.            
  52.             }
  53.  
  54.             Console.WriteLine();
  55.  
  56.             for (int i = 0; i < n; i++)
  57.             {
  58.                 Console.WriteLine(A[i]);
  59.            
  60.             }
  61.            
  62.             Console.ReadKey();
  63.        
  64.         }
  65.        
  66.  
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement