Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <time.h>
- #include <stdlib.h>
- #define TAM 100
- void gerarProdutividade(int campo[TAM][TAM], int N, int M){
- int i,j;
- for(i=0;i<N;i++)
- for(j=0;j<M;j++)
- campo[i][j]=rand()%501;
- }
- void verificarProduccao (int campo[TAM][TAM], int N, int M, int *maiorProd){
- int i, j, soma;
- for(i=0;i<N;i++){
- soma=0;
- for(j=0;j<M;j++){
- soma=soma+campo[i][j];
- }
- if(soma>*maiorProd){
- *maiorProd = soma;
- }
- }
- for(j=0;j<M;j++){
- soma=0;
- for(i=0;i<N;i++){
- soma=soma+campo[i][j];
- }
- if(soma>*maiorProd){
- *maiorProd = soma;
- }
- }
- }
- int main(void) {
- int campo[TAM][TAM], N, M, maiorProd=0;
- printf("Insira os tamanhos do retangulo: ");
- scanf("%d %d", &N, &M);
- srand(time(NULL));
- gerarProdutividade(campo, N, M);
- verificarProduccao(campo, N, M, &maiorProd);
- printf("%d", maiorProd);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement