TOPIC

Presentation Error

João Victor Pulheis Sierra asked 1 year ago

Olá, não consigo achar o que falta aqui para receber o AC:

#include <stdio.h>
#include <iostream>
#include <iomanip>  

#define TFL 20
#define TFC 20

using namespace std;

unsigned long long int numDig(unsigned long long int n)
{
    unsigned long long int c = 0;

    if(c == 0)
        return 1;
    else
    {
        while(n > 0)
        {
            c++;
            n /= 10;
        }

        return c;
    }
}

unsigned long long int AchaMaior(unsigned long long int mat[TFL][TFC], unsigned long long int m, 
                                unsigned long long int col)
{
    int l, c;
    unsigned long long int maior = 0;

    for(l = 0; l < m; l++)
        if(mat[l][col] > maior)
            maior = numDig(mat[l][col]);

    return maior;
}

int main(void)
{
    unsigned long long int nc, i, j, k, m, x = 4;
    unsigned long long int mat[TFL][TFC];
    unsigned long long int maiores[TFL];

    scanf("%lld", &nc);

    for(i = 0; i < nc; i++)
    {
        scanf("%llu", &m);

        for(j = 0; j < m; j++)
            for(k = 0; k < m; k++)
            {
                scanf("%llu", &mat[j][k]);
                mat[j][k] *= mat[j][k];
            }

        for(j = 0; j < m; j++)
            maiores[j] = AchaMaior(mat, m, j);      

        if(i > 0)
            printf("\n");

        cout << "Quadrado da matriz #" << x << ":" << endl;

        for(j = 0; j < m; j++)
        {
            for(k = 0; k < m; k++)
            {
                cout << setw(maiores[k]);
                cout << mat[j][k];

                if(k < m - 1)
                    printf(" ");
            }

            if(i < nc - 1 || j < m - 1)
                printf("\n");
        }

        x++;
    }

    return 0;
}

This topic has not been answered yet. Be the first!

Remember not post solutions. Your post may be reviewed by our moderators.