Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4. namespace ConsoleApp1
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. int n;
  11. Console.WriteLine("Unesi broj elemenata niza:");
  12. n = Convert.ToInt32(Console.ReadLine());
  13.  
  14. int k;
  15. Console.WriteLine("Unesi broj k:");
  16. k = Convert.ToInt32(Console.ReadLine());
  17.  
  18. int m;
  19. Console.WriteLine("Unesi broj m:");
  20. m = Convert.ToInt32(Console.ReadLine());
  21.  
  22. int[] niz = new int[n];
  23. Console.WriteLine("Unesi elemente niza:");
  24. for (int i = 0; i < n; i++)
  25. niz[i] = Convert.ToInt32(Console.ReadLine());
  26.  
  27. for (int i = 0, j = 0; j < k; i++, j++)
  28. {
  29. niz[j] = niz[j] - m;
  30. }
  31.  
  32. Console.WriteLine("Niz:");
  33. foreach (int element in niz)
  34. Console.Write(element + " ");
  35. Console.WriteLine();
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement