Advertisement
Guest User

zadatak br7

a guest
Oct 18th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. 7. Napisati program koji sve elemente celobrojnog niza od početka niza do k-tog elementa smanjuje za broj m
  2. using System;
  3.  
  4. namespace ConsoleApplication
  5. {
  6. public class Program
  7. {
  8. public 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[] niz = new int[n];
  15. Console.WriteLine("Unesi elemente niza:");
  16. for (int i = 0; i < n; i++)
  17. niz[i] = Convert.ToInt32(Console.ReadLine());
  18. int k;
  19. Console.WriteLine("Unesi broj k:");
  20. k = Convert.ToInt32(Console.ReadLine());
  21.  
  22. int m;
  23. Console.WriteLine("Unesi broj m:");
  24. m = Convert.ToInt32(Console.ReadLine());
  25.  
  26. for(i=0; i<n i++)
  27. if niz[i]<k
  28. niz[i]=niz[i]-m;
  29.  
  30. Console.WriteLine("Niz nakon dodavanja m:");
  31. Console.Write(element + " ");
  32. Console.WriteLine();
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement