Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  5.  
  6. void prawo(int tab[])
  7. {
  8. int a,i;
  9. printf("Podaj o ile tablica ma sie przesunac w prawo: ");
  10. scanf("%d",&a);
  11. int b=10-a;
  12. for(i=0;i<a;i++)
  13. {
  14. int cos=tab[i];
  15. tab[i]=0;
  16. printf("%d ",tab[i]);
  17. tab[i]=cos;
  18. }
  19. for(i=0;i<b;i++)
  20. {
  21. printf("%d ",tab[i]);
  22. }
  23. printf("\n");
  24. }
  25. void lewo(int tab[])
  26. {
  27. int a,i;
  28. printf("Podaj o ile tablica ma sie przesunac w lewo: ");
  29. scanf("%d",&a);
  30. int b=10-a;
  31. for(i=0;i<b;i++)
  32. {
  33. printf("%d ",tab[i]);
  34. }
  35. for(i=0;i<a;i++)
  36. {
  37. tab[i]=0;
  38. printf("%d ",tab[i]);
  39. }
  40. }
  41. int main(int argc, char *argv[])
  42. {
  43. int tab[10]={100,110,120,130,140,150,160,170,180,190};//wielkosc tablicy miala byc zwiazana z nr stanowiska wiec zmienisz na lekcji
  44. prawo(tab);
  45. lewo(tab);
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement