Advertisement
olekturbo

odejmowanie

Nov 14th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. // ODEJMOWANIE DUZYCH LICZB
  2. // ALEKSANDER SZEWCZAK
  3. #include <stdio.h>
  4.  
  5. int main(void)
  6. {
  7. unsigned int ile;
  8. int i;
  9. printf("Ile liczb maja miec cyfry? ");
  10. scanf("%d", &ile);
  11.  
  12. int tab[ile], tab2[ile], w[ile];
  13. printf("Wypisz liczbe nr 1: ");
  14. for(i = 0; i < ile; i++) scanf("%1d", &tab[i]);
  15.  
  16. printf("Wypisz liczbe nr 2: ");
  17. for(i = 0; i < ile; i++) scanf("%1d", &tab2[i]);
  18.  
  19. for(i = 0; i < ile; i++) printf("%1d", tab[i]);
  20. printf(" - ");
  21. for(i = 0; i < ile; i++) printf("%1d", tab2[i]);
  22. printf(" = ");
  23.  
  24. for(i = 0; i < ile; i++)
  25. {
  26. w[i] = 0;
  27.  
  28. }
  29.  
  30. for(i = 0; i < ile; i++)
  31. {
  32. w[i] += tab[i];
  33. w[i] -= tab2[i];
  34. if(w[i] < 0)
  35. {
  36. w[i-1] -= 1;
  37. w[i] +=10;
  38. }
  39. }
  40.  
  41.  
  42. for(i = 0; i < ile; i++) printf("%d", w[i]);
  43.  
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement