Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int fun(int **tab[], int n){
  4. int s=0, i, temp=0, j,tempa,tempb;
  5. for(i=0; i<n; i++)
  6. {
  7. printf("suma obecna: %d\n",s);
  8. printf("Wartosc: %d\n", *(tab+i));
  9. printf("Adres: %p\n", tab+i);
  10. temp=*(tab+i);
  11. s=s+temp;
  12. printf("suma po dodaniu: %d\n",s);
  13. j=i+1;
  14. for(j; j<n; j++) {
  15. tempa=*(tab+i);
  16. tempb=*(tab+j);
  17. printf("Wartosc porownywana: %d\n", *(tab+i));
  18. printf("Wartosc do ktorej porownujemy: %d\n", *(tab+j));
  19. if(tempa==tempb) *(tab+j)=0;
  20. printf("Wartosc po wyzerowaniu: %d\n", *(tab+i));
  21. }
  22. }
  23. return s;
  24. }
  25.  
  26. int main(){
  27. int *tab[]={1,2,1,2,3,4,3,4,5};
  28. printf("%d ", fun(tab,9));
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement