Advertisement
simonradev

FixedCode

Feb 13th, 2017
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. public class Program
  4. {
  5.     public static void Main(string[] args)
  6.     {
  7.         string charValues = Console.ReadLine();
  8.         int[] intValues = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  9.         char[] result = new char[intValues.Length];
  10.         for (int i = 0; i < intValues.Length; i++)
  11.         {
  12.             //в иф-а трябва да проверяваш не дали елемента от масива с числата е на четен или нечетен индекс
  13.             //а да проверяваш самия елемент на даденото място дали е четен или не
  14.             if (intValues[i] % 2 == 0)
  15.             {
  16.                 result[i] = (char)(charValues[i] - intValues[i]);
  17.             }
  18.             else
  19.             {                               //тук не е '-' а '+'
  20.                 result[i] = (char)(charValues[i] + intValues[i]);
  21.             }
  22.         }
  23.  
  24.         Console.WriteLine(string.Join("", result));
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement