Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- /* run this program using the console pauser or add your own getch, system("pause") or input loop */
- void prawo(int tab[])
- {
- int a,i;
- printf("Podaj o ile tablica ma sie przesunac w prawo: ");
- scanf("%d",&a);
- int b=10-a;
- for(i=0;i<a;i++)
- {
- int cos=tab[i];
- tab[i]=0;
- printf("%d ",tab[i]);
- tab[i]=cos;
- }
- for(i=0;i<b;i++)
- {
- printf("%d ",tab[i]);
- }
- printf("\n");
- }
- void lewo(int tab[])
- {
- int a,i;
- printf("Podaj o ile tablica ma sie przesunac w lewo: ");
- scanf("%d",&a);
- int b=10-a;
- for(i=0;i<b;i++)
- {
- printf("%d ",tab[i]);
- }
- for(i=0;i<a;i++)
- {
- tab[i]=0;
- printf("%d ",tab[i]);
- }
- }
- int main(int argc, char *argv[])
- {
- 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
- prawo(tab);
- lewo(tab);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement