misiek06

Untitled

Dec 5th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2. void main()
  3. {
  4. int x, a, b, n = 0, t[100];
  5. printf("\nPodaj liczbe naturalna: ");
  6. scanf("%d", &x);
  7. a = x;
  8. printf("\nPodaj baze reprezentacji (2-9): ");
  9. scanf("%d", &b);
  10. if(b<2 || b>9)
  11. {
  12. printf("\nNiepoprawna wartosc bazy!!\n");
  13. return;
  14. }
  15. while(x)
  16. {
  17. t[n] = x % b;
  18. n++;
  19. if(n >= 100) break;
  20. x = x / b;
  21. }
  22. printf("\n%d(10) = ", a);
  23. while(n)
  24. {
  25. n--;
  26. printf("%d", t[n]);
  27. }
  28. printf("(%d)\n\n\n", b);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment