Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2011
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.44 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main( )
  5. {
  6.     int linhas,colunas, i, j;
  7.     int n,k;
  8.     int h;
  9.     int custo;
  10.    
  11.     //inicializa o custo
  12.     custo = 0;
  13.  
  14.     printf("Entre com o numero de cidades:");
  15.     scanf("%d",&k);
  16.     printf("Entre com o numero de itinerarios:");
  17.     scanf("%d",&n);
  18.     printf("Entre com o comprimento do itinerarios:");
  19.     scanf("%d",&h);
  20.  
  21.     /*Entrar com a dminsão da matriz desejada*/
  22.     printf("Entre com o numero de linhas: ");
  23.     scanf("%d",&linhas);
  24.     printf("Entre com o numero de colunas: ");
  25.     scanf("%d",&colunas);
  26.  
  27.     /*declaração das matrizes que serão usadas no programa*/
  28.     int matCustos[linhas][colunas];
  29.  
  30.         /*laço de repetição para entrar com os valores da matriz 1*/
  31.         for (i=0; i<linhas; i++) {
  32.           for(j=0; j<colunas; j++)
  33.           {
  34.           printf(" Entre com os elementos da matriz 1 [%d][%d]:",i+1,j+1);
  35.           scanf("%d",&matCustos[i][j]);
  36.  
  37.          }
  38.        }
  39.  
  40.            /*Mostra a matriz 1 criada*/
  41.            printf("\n\Matriz de custo \n\n");
  42.              for (i=0; i<linhas; i++)
  43.              {
  44.                 for(j=0; j<colunas;j++)
  45.                 printf("%3.d\t",mat1[i][j]);
  46.                 printf("\n\n");
  47.              }
  48.  
  49.              custo = custo + itinerario[k][k+1];
  50.               printf("\n\n\n");
  51.               printf("O valor total eh %d",custo)
  52.               getch();
  53.               return 0;
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement