Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.53 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp12
  8. {
  9.     class Program
  10.     {
  11.         static void Main()
  12.         {
  13.             int counter = -1;
  14.             List<string> str = new List<string>();
  15.             do //ввод строк
  16.             {
  17.                 str.Add(Console.ReadLine());
  18.                 counter++;
  19.  
  20.             }
  21.             while (str[counter]!= "");// проверка конца ввода, если пустая строка значит ввод окончен
  22.  
  23.  
  24.             int t1 = 0, t2 = 0, t3 = 0, t4 = 0; // количество комментариев каждого типа
  25.        
  26.             int end_i = -1, end_j = -1;// конец комментария
  27.             bool isComment = false; //метка комментария
  28.             string typeOfComment = "0"; // тип комментария
  29.             for (int i = 0; i < counter; i++)
  30.             {
  31.                 Console.WriteLine("shag " + i);
  32.                 if (i > end_i)
  33.                 {
  34.                     for (int j = 0; j < str[i].Length; j++)
  35.                     {
  36.                         Console.WriteLine("shag stroki " + j);
  37.                         if (j > end_j)
  38.                         {
  39.                             if (!isComment)
  40.                             {
  41.                                 if ((str[i][j] == '(') && (str[i][j + 1] == '*'))
  42.                                 {
  43.  
  44.                                     isComment = true;
  45.                                     typeOfComment = "1";
  46.                                 }
  47.                             }
  48.                             else
  49.                             {
  50.                                 if ((str[i][j] == '*') && (str[i][j + 1] == ')'))
  51.                                 {
  52.                                     if (typeOfComment == "1")
  53.                                     {
  54.                                         isComment = false;
  55.                                         end_i = i; end_j = j+1;
  56.                                         Console.WriteLine(end_i + " " + end_j);
  57.                                         t1++;
  58.                                     }
  59.                                        
  60.                                 }
  61.                             }
  62.                         }
  63.                     }
  64.                 }
  65.             }
  66.             Console.WriteLine(t1+" "+t2+" "+t3+" "+t4);
  67.             Console.ReadLine();
  68.  
  69.         }
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement