#include <stdio.h>
#include<conio.h>
#include <string.h>
void main (void)
{
char cp[4],tm[4],vtm[2][4],vcp[4][4];
int cant;
int mt[4][2]={0};
for(int i=0; i<2; i++)
{
printf("tipo maq. 2mx(4 string)" ); //cargo 1 lote
fflush(stdin);
gets(vtm[i]);
}
int x=0;
printf("cant ");
scanf("%d",&cant);
while(cant!=0)
{
printf("tipo maq. 2mx(4 string)" );
fflush(stdin);
gets(tm);
printf("cod. pais 4mx( 4 string" );
fflush(stdin);
gets(cp);
int k=0;
while(strcmp(vtm[k],tm)!=0 && k<2)
{
k++; //busca si existe la maquina y salta su posicion
}
int h=0;
while(h<x && strcmp(vcp[h],cp)!=0)
{
h++; //inserto cod. de pais
}
if(h>=x)
{
strcpy(vcp[h],cp);
x++; //insercion de cadena
}
mt[h][k]+=cant; // acumulo la cantidad total para cada pais y tipo de maquina
printf("cant ");
scanf("%d",&cant);
}
int aux;
for(int a=0; a<2; a++)
{
for(int b=0; b<3; b++)
{
for(int c=b+1; c<4; c++)
{
if(mt[b][a]<mt[c][a])
{ // quiero ordenar matriz en orden decreciente x cantidad total
aux=mt[b][a]; //ordenar por columnas
mt[b][a]=mt[c][a];
mt[c][a]=aux; // no funka
}
}
}
}
for(int r=0; r<4; r++)
{
for(int s=0; s<2; s++)
{
printf( " cod. pais %s tipo maquinaria %s total cantidad %d \n",vcp[r],vtm[s],mt[r][s]);
}
} // total cantidad tiene que salir en forma decreciente
}