Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3.  
  4. #define N 100
  5. struct _Decimal
  6. {
  7.     char a[N];
  8.     unsigned int n;
  9.  
  10. };
  11.  
  12. typedef struct _Decimal Decimal;
  13.  
  14. void div10(Decimal* res, const Decimal* b)
  15. {
  16.     unsigned int n = b->n;
  17.     res->a[0] = b->a[n - 1];
  18.     res->a[1] = b->a[n];
  19. }
  20.  
  21. int main(){
  22.     Decimal a = {{7, 4, 1}, 2};  // set number 147
  23.     Decimal res;
  24.  
  25.     div10(&res, &a);           // res = a/10 = 147/10 = 14
  26.  
  27.     printf("%u", &res);          // print 14
  28.     printf("\n");
  29.  
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement