Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- void Inicializar (float M[][100])
- { int i, j;
- for (i=0; i<2; i++)
- {
- for (j=0;j<2; j++)
- {
- printf ("[%d][%d] = ", i, j);
- scanf ("%f", &M[i][j]);
- }
- }
- }
- void maior (float M[][100])
- {
- int i, j;
- float maioralt;;
- for (i=0; i<2; i++)
- {
- for (j=0;j<2; j++)
- {
- if (M[i][j]>M[0][0])
- maioralt = M[i][j];
- }
- }
- printf ("\n A maior altura e': %f", maioralt);
- }
- void desnivel (float M[][100])
- {
- int i1, j1, i2, j2, c;
- float dif, des = 0;
- printf ("\n Digite as coordenadas do ponto 1: ");
- scanf("%d", &i1);
- scanf ("%d", &j1);
- printf ("\n Digite as coordenadas do ponto 2: ");
- scanf("%d", &i2);
- scanf ("%d", &j2);
- // distancia de (i1, j1) até (i1, j2)//
- for (c = j1; c !=j2; c++)
- { dif = M[i1][c] - M[i1][c+1];
- if (dif<0)
- {
- dif= -dif;
- }
- des += dif; // des = des + dif;//
- }
- for (c = i1; c!= j2; c++)
- {
- dif = M[c][j2]-M[c+1][j2];
- if (dif<0)
- { dif = - dif;}
- des+= dif; // des = des + dif;//
- }
- printf ("\n O Desnivel total: %.2f \n", des);
- }
- main ()
- {
- float matriz[100][100];
- Inicializar(matriz);
- maior(matriz);
- desnivel(matriz);
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement