Răspuns :
#include "stdafx.h"
#include "iostream"
using namespace std;
void main()
{
int m, n, contor = 0,suma = 0;
int*mat;
int*arr;
bool eDistinct;
do{
cin >> n >> m;
if ((n > 100 || n < 0) || (m > 100 || m < 0)) {
cout << "Introduceti numere de la 0 la 100";
}
} while ((n > 100 || n < 0) || (m > 100 || m < 0));
mat = new int[n,m];
arr = new int[n*m];
cout << "Introduceti numerele:\n";
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) { do {
cin >> mat[i, j];
if (mat[i, j] > 10000 || mat[i, j] < 0) {
cout << "Numerele trebuie sa fie mai mici ca 10000!\n";
}
} while (mat[i, j] > 10000 || mat[i,j] < 0);
if (mat[i, j] % 2 == 0) {
eDistinct = true;
for (int g = 0; g < contor; g++) {
if (arr[g] == mat[i,j]) {
eDistinct = false;
}
}
if (eDistinct || contor == 0) {
arr[contor] = mat[i, j];
contor = contor + 1;
}
}
}
}
for (int i = 0; i < contor; i++) {
suma = suma + arr[i];
}
cout << "Suma este:"<<suma << endl << endl;
system("pause");
delete mat;
delete arr;
}
#include "iostream"
using namespace std;
void main()
{
int m, n, contor = 0,suma = 0;
int*mat;
int*arr;
bool eDistinct;
do{
cin >> n >> m;
if ((n > 100 || n < 0) || (m > 100 || m < 0)) {
cout << "Introduceti numere de la 0 la 100";
}
} while ((n > 100 || n < 0) || (m > 100 || m < 0));
mat = new int[n,m];
arr = new int[n*m];
cout << "Introduceti numerele:\n";
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) { do {
cin >> mat[i, j];
if (mat[i, j] > 10000 || mat[i, j] < 0) {
cout << "Numerele trebuie sa fie mai mici ca 10000!\n";
}
} while (mat[i, j] > 10000 || mat[i,j] < 0);
if (mat[i, j] % 2 == 0) {
eDistinct = true;
for (int g = 0; g < contor; g++) {
if (arr[g] == mat[i,j]) {
eDistinct = false;
}
}
if (eDistinct || contor == 0) {
arr[contor] = mat[i, j];
contor = contor + 1;
}
}
}
}
for (int i = 0; i < contor; i++) {
suma = suma + arr[i];
}
cout << "Suma este:"<<suma << endl << endl;
system("pause");
delete mat;
delete arr;
}
Vă mulțumim pentru vizita pe site-ul nostru dedicat Informatică. Sperăm că informațiile disponibile v-au fost utile și inspiraționale. Dacă aveți întrebări sau aveți nevoie de suport suplimentar, suntem aici pentru a vă ajuta. Ne face plăcere să vă revedem și vă invităm să adăugați site-ul nostru la favorite pentru acces rapid!