|  | 
|  | 
| back to board | C# Please, Help! Where is wrong? Posted by Serge  12 Jan 2018 05:28The answer is correct, but it returns an error. Why? Maybe I did not understand the condition of the task correctly, or can the data be specified for which this code will produce the wrong solution?
 
 using System;
 
 namespace ConsoleApp30
 {
 class Program
 {
 static void Main(string[] args)
 {
 int n = int.Parse(Console.ReadLine());
 int x = 0;
 string[] shoplist = new string[n];
 for (int i = 0; i <n; i++)
 {
 shoplist[i] = Console.ReadLine();
 }
 
 for (int i = 0; i < shoplist.Length; i++)
 {
 for (int j = i + 1; j<shoplist.Length; j++)
 {
 if (shoplist[i] == shoplist[j])
 {
 x++;
 i++;
 }
 else
 {
 continue;
 }
 }
 }
 
 Console.WriteLine(x);
 //Console.ReadKey();
 }
 }
 }
 | 
 | 
|