Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 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.  
  28. for (int i = 0; i < n; i++)
  29. {
  30. if (niz[i] < k)
  31. {
  32. niz[i] = niz[i] - m;
  33. }
  34. }
  35.  
  36. Console.WriteLine("Niz:");
  37. foreach (int element in niz)
  38. Console.Write(element + " ");
  39. Console.WriteLine();
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement