Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.88 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void printSpace(int x)
  4. {
  5.     int i;
  6.     for(i = 0; i < x; i++)
  7.         printf(" ");
  8. }
  9.  
  10. int findn(long double num)
  11. {
  12.    if ( num < 10 )
  13.       return 1;
  14.    if ( num < 100 )
  15.       return 2;
  16.   if ( num < 1000 )
  17.       return 3;
  18.   if ( num < 10000 )
  19.       return 4;
  20.   if ( num < 100000 )
  21.       return 5;
  22.   if ( num < 1000000 )
  23.       return 6;
  24.   if ( num < 10000000 )
  25.       return 7;
  26.   if ( num < 100000000 )
  27.       return 8;
  28.   if ( num < 1000000000 )
  29.       return 9;
  30.   if ( num < 10000000000 )
  31.       return 10;
  32.   if ( num < 100000000000 )
  33.       return 11;
  34.   if ( num < 1000000000000 )
  35.       return 12;
  36.   if ( num < 10000000000000 )
  37.       return 13;
  38.   if ( num < 100000000000000 )
  39.       return 14;
  40.   if ( num < 1000000000000000 )
  41.       return 15;
  42.      
  43. }
  44.  
  45. int main(void)
  46. {
  47.     int n, i, l, c;
  48.     long double mat[20][20];
  49.     long double mat2[20][20];
  50.     long double col[20];
  51.  
  52.     scanf("%d", &n);
  53.  
  54.     for(i = 0; i < n; i++)
  55.     {
  56.          
  57.         int k;
  58.         scanf("%d", &k);
  59.          
  60.         /*for(l = 0; l < k; l++)
  61.             col[l] = -1;*/
  62.         long double a;
  63.         for(l = 0; l < k; l++)
  64.             for(c = 0; c < k; c++)
  65.             {
  66.                 scanf("%llf", &a);
  67.                 mat[l][c] = a*a;
  68.  
  69.                 a = findn(mat[l][c]);
  70.                 mat2[l][c] = a;
  71.                 if(a > col[c])
  72.                     col[c] = a;
  73.             }
  74.         printf("Quadrado da matriz #%d:\n", i+4);
  75.         for(l = 0; l < k; l++)
  76.         {
  77.             for(c = 0; c < k; c++)
  78.             {
  79.                 printSpace(col[c]-mat2[l][c]);
  80.                 if(c != 0)
  81.                     printf(" %.llf", mat[l][c]);
  82.                 else
  83.                     printf("%.llf", mat[l][c]);
  84.                  
  85.             }
  86.             printf("\n");
  87.         }
  88.         printf("\n");
  89.     }
  90.  
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement