Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- int sum = int.Parse(Console.ReadLine());
- int number = int.Parse(Console.ReadLine());
- int p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16 = 0;
- int p = int.Parse(Console.ReadLine());
- int count = 0;
- int answer = 0;
- for (int i = 1; i <= number; i++)
- {
- while (count != sum)
- {
- if (i == 1) { p1 = int.Parse(Console.ReadLine()); count = p1; }
- if (i == 2) { p2 = int.Parse(Console.ReadLine()); count = count + p2; }
- if (i == 3) { p3 = int.Parse(Console.ReadLine()); count = count + p3; }
- if (i == 4) { p4 = int.Parse(Console.ReadLine()); count = count + p4; }
- if (i == 5) { p5 = int.Parse(Console.ReadLine()); count = count + p5; }
- if (i == 6) { p6 = int.Parse(Console.ReadLine()); count = count + p6; }
- if (i == 7) { p7 = int.Parse(Console.ReadLine()); count = count + p7; }
- if (i == 8) { p8 = int.Parse(Console.ReadLine()); count = count + p8; }
- if (i == 9) { p9 = int.Parse(Console.ReadLine()); count = count + p9; }
- if (i == 10) { p10 = int.Parse(Console.ReadLine()); count = count + p10; }
- if (i == 10) { p11 = int.Parse(Console.ReadLine()); count = count + p11; }
- if (i == 12) { p12 = int.Parse(Console.ReadLine()); count = count + p12; }
- if (i == 13) { p13 = int.Parse(Console.ReadLine()); count = count + p13; }
- if (i == 14) { p14 = int.Parse(Console.ReadLine()); count = count + p14; }
- if (i == 15) { p15 = int.Parse(Console.ReadLine()); count = count + p15; }
- if (i == 16) { p16 = int.Parse(Console.ReadLine()); count = count + p16; }
- }
- answer = answer + 1;
- }
- for (int i = 0; i < number; i++)
- {
- while (p != sum)
- {
- Console.WriteLine("Enter element p = ");
- p = p + int.Parse(Console.ReadLine());
- break;
- }
- answer = answer + 1;
- }
- Console.WriteLine(answer);
- }
- }
- m
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement