Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <assert.h>
- #include <stdbool.h>
- #define MAX_DL 500
- #define MAX_W 10
- typedef int TLiczba[MAX_DL];
- void init (TLiczba liczba, int wart)
- {
- int i=0;
- while (i < MAX_DL)
- {
- liczba [i]=wart%MAX_W;
- wart = wart / MAX_W;
- i++;
- }
- assert(wart==0);
- }
- bool dodaj (TLiczba x, TLiczba y, TLiczba z)
- {
- int i=0, temp=0;
- while (i < MAX_DL)
- {
- z[i]=(x[i] + y[i] + temp)%MAX_W;
- temp=(x[i] + y[i] + temp)/MAX_W;
- i++;
- }
- }
- void kopiuj (TLiczba skad, TLiczba dokad)
- {
- for (int i=0; i < MAX_DL; i++)
- {
- dokad[i]=skad[i];
- }
- }
- void wypisz (TLiczba a)
- {
- int dl=MAX_DL -1;
- while (a[dl]==0 && dl>0) dl--;
- //printf ("%d",a[dl]);
- while (dl>=0)
- {
- printf("%d", a[dl]);
- dl --;
- }
- }
- int main()
- {
- TLiczba x;
- init (x, 1);
- for (int i=1; i<=10; i++)
- {
- TLiczba y;
- dodaj (x,x,y);
- kopiuj(y,x);
- }
- printf("2^10=");
- wypisz (x);
- printf ("\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement