[ create a new paste ] login | about

Link: http://codepad.org/QRn8WJJV    [ raw code | output | fork ]

axell13 - C++, pasted on Oct 29:
#include <iostream>
using namespace std;
#define m 3
#define n 3

int main(){
	int matriz[m][n], i, j, somapar = 0, somaimpar = 0;

	for (i = 0; i < m; i++){

		for (j = 0; j < n; j++){

			printf("Informe Matriz[%i][%i]: ", i, j);
			cin >> matriz[i][j];

		}

	}

	for (i = 0; i < m; i++){

		for (j = 0; j < n; j++){

			if (matriz[i][j] % 2 == 1){

				somaimpar += matriz[i][j];

			}

			else if (matriz[i][j] % 2 == 0){

				somapar += matriz[i][j];

			}

			}

		}

	printf("\nSoma Dos Pares: %i\nSoma Dos Impares: %i", somapar, somaimpar);
	cin.ignore();
	cin.ignore();
	return 0;
}


Output:
1
2
3
Informe Matriz[0][0]: Informe Matriz[0][1]: Informe Matriz[0][2]: Informe Matriz[1][0]: Informe Matriz[1][1]: Informe Matriz[1][2]: Informe Matriz[2][0]: Informe Matriz[2][1]: Informe Matriz[2][2]: 
Soma Dos Pares: -459739284
Soma Dos Impares: 134535525


Create a new paste based on this one


Comments: