fork download
  1. #include <stdio.h>
  2.  
  3. typedef unsigned int Uint;
  4. #define N 100
  5. #define DP 1
  6. //RADIX == 10^LOG
  7. #define LOG 1
  8. #define RADIX 10
  9. typedef Uint Liczba[N+1];
  10.  
  11. void plus( Liczba a, Liczba b){ // a[]:=a[]+b[]
  12. for( Uint c=0, i=N; i>0; i-- ){
  13. c += a[i]+b[i];
  14. a[i] = c % RADIX;
  15. c /= RADIX;}}
  16.  
  17. void minus( Liczba a, Liczba b) { // a[]:=a[]-b[]
  18. for( Uint c=0, i=N; i>0; i-- ){
  19. c += b[i];
  20. if( a[i]<c ){
  21. a[i] = RADIX + a[i] - c; c=1; }
  22. else {
  23. a[i] -= c; c=0; }}}
  24.  
  25. void razyU( Liczba a, Uint b ) { // a[]:=a[] * b
  26. for( Uint c=0,i=N; i>0; i-- ){
  27. c += a[i]*b;
  28. a[i]= c % RADIX;
  29. c /= RADIX; }}
  30.  
  31. void pisz( Liczba a ){
  32. printf("%*u.", LOG, a[1]);
  33. for( i=2; i<DP; i++ ) printf("%0*u", LOG, a[i]);
  34. putchar(".");
  35. for( ; i<=N; i++ ) printf("%0*u", LOG, a[i]); }
  36.  
  37. int main(void) {
  38. Liczba
  39. a={0,1,0,9,0},
  40. b={0,2,0,5,1};
  41. plus(a, b); pisz(a); puts("");
  42. razyU(a, 5); pisz(a);
  43. return 0;
  44. }
  45.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘pisz’:
prog.c:33: error: ‘i’ undeclared (first use in this function)
prog.c:33: error: (Each undeclared identifier is reported only once
prog.c:33: error: for each function it appears in.)
cc1: warnings being treated as errors
prog.c:34: error: passing argument 1 of ‘putchar’ makes integer from pointer without a cast
stdout
Standard output is empty