Advertisement
Asinka

01. Cartesian Coordinate System (Sample Exam))

Dec 26th, 2012
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.26 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4.  
  5. class Program
  6. {
  7.     static void Main()
  8.     {
  9.         int sum = int.Parse(Console.ReadLine());
  10.         int number = int.Parse(Console.ReadLine());
  11.         int p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16 = 0;
  12.         int p = int.Parse(Console.ReadLine());
  13.         int count = 0;
  14.         int answer = 0;
  15.  
  16.         for (int i = 1; i <= number; i++)
  17.         {
  18.             while (count != sum)
  19.             {
  20.                 if (i == 1) { p1 = int.Parse(Console.ReadLine()); count = p1; }
  21.                 if (i == 2) { p2 = int.Parse(Console.ReadLine()); count = count + p2; }
  22.                 if (i == 3) { p3 = int.Parse(Console.ReadLine()); count = count + p3; }
  23.                 if (i == 4) { p4 = int.Parse(Console.ReadLine()); count = count + p4; }
  24.                 if (i == 5) { p5 = int.Parse(Console.ReadLine()); count = count + p5; }
  25.                 if (i == 6) { p6 = int.Parse(Console.ReadLine()); count = count + p6; }
  26.                 if (i == 7) { p7 = int.Parse(Console.ReadLine()); count = count + p7; }
  27.                 if (i == 8) { p8 = int.Parse(Console.ReadLine()); count = count + p8; }
  28.                 if (i == 9) { p9 = int.Parse(Console.ReadLine()); count = count + p9; }
  29.                 if (i == 10) { p10 = int.Parse(Console.ReadLine()); count = count + p10; }
  30.                 if (i == 10) { p11 = int.Parse(Console.ReadLine()); count = count + p11; }
  31.                 if (i == 12) { p12 = int.Parse(Console.ReadLine()); count = count + p12; }
  32.                 if (i == 13) { p13 = int.Parse(Console.ReadLine()); count = count + p13; }
  33.                 if (i == 14) { p14 = int.Parse(Console.ReadLine()); count = count + p14; }
  34.                 if (i == 15) { p15 = int.Parse(Console.ReadLine()); count = count + p15; }
  35.                 if (i == 16) { p16 = int.Parse(Console.ReadLine()); count = count + p16; }
  36.             }
  37.             answer = answer + 1;
  38.         }
  39.  
  40.         for (int i = 0; i < number; i++)
  41.         {
  42.  
  43.             while (p != sum)
  44.             {
  45.                 Console.WriteLine("Enter element p = ");
  46.                 p = p + int.Parse(Console.ReadLine());
  47.                 break;
  48.             }
  49.             answer = answer + 1;
  50.         }
  51.         Console.WriteLine(answer);
  52.  
  53.     }
  54. }
  55.  
  56. m
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement