You are on page 1of 4

1.

Sa se introduca N
2. Sa se faca N int
3. Se fac 2 siruri pentru x si y
4. Se initializeaza punctul de plecare (0,0)
5. In functie de input : up, down, right, left se incrementeaza/decrementeaza x/y
6. Se trece prin succesiunea de inputuri, si se stocheaza pt fiecare i x /y
7. Se trece prin fiecare sir si se determina daca x/y de pe aceasi pozitie se mai gaseste si la alta
pozitie
8. Print rezultat

down 0 -1
right 1 -1
down 1 -2
left 0 -2
up 0 -1
left -1 -1

pointX = {0,0,1,1,0,0,-1}

point Y={0,-1,-1,-2,-2,-1,-1}

{0,0}

{0,-1} => result=true;

For (i=0;i<pointx.length;i++}

For (j=0;j<pointX.Length;j++)

If ( pointsX[i]==pointsx[j] &&pointY[i]==pointsY[j])

Result=true;
Ion 7 - 1

Ana 8 – 1+1=2

Ene 9 – 1+1=2+1=3

Ina 10- 1

Ion

Ana

Ene

Ina

10

using System;
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
string numberOfKids = Console.ReadLine();
int n = Convert.ToInt32(numberOfKids);
string[] names = new string[n];
string[] grades = new string[n];
int[] coins = new int[6];
for (int i = 0; i < n; i++)
{
names[i] = Console.ReadLine();
}
for (int i = 0; i < n; i++)
{
grades[i] = Console.ReadLine();
coins[i] = 1;
}
for (int k = 0; k < n - 1; k++)
{
if (Convert.ToInt32(grades[k]) > Convert.ToInt32(grades[k + 1]))
{
coins[k]++;

}
}
if (Convert.ToInt32(grades[n - 1]) > Convert.ToInt32(grades[0]))
{
coins[n - 1]++;
}
if (Convert.ToInt32(grades[n - 1]) < Convert.ToInt32(grades[0]))
{
coins[0]++;
}
for (int a = n - 1; a >= 1; a--)
{
if (Convert.ToInt32(grades[a]) > Convert.ToInt32(grades[a - 1]))
{
coins[a]++;
}
}
for (int x=0;x<n-1;x++)
{
if (coins[x] <= coins[x + 1])
{
if (Convert.ToInt32(grades[x]) > Convert.ToInt32(grades[x + 1]))
{
coins[x]++;
}
}
}
for (int x = n-1; x >=1; x--)
{
if ( coins[x] <= coins[x - 1])
{
if( Convert.ToInt32(grades[x]) > Convert.ToInt32(grades[x - 1]))
coins[x]++;
}
}
for (int j = 0; j < n; j++)
{
Console.WriteLine(names[j] + " " + coins[j]);
}
Console.Read();
}
}
}

8 1 1
9 1 1
10 1 1
10 1 2
8 1 1
8 1 2
6 1 1 1
9 1 2 3
8 1 1 1

You might also like