Tylko dodatnie:
#include <iostream>
using namespace std;
int main() {
int tablica[10] = {1, 2, 3, -1, -2, -3, 5, 4, 3, 11};
cout << "Tylko dodatnie: ";
for (auto i = 0; i < 10; i++) {
if (tablica[i] > 0) {
cout << tablica[i] << " ";
}
}
cout << endl;
return 0;
}
SUMA:
#include <iostream>
using namespace std;
int main() {
int tablica[10] = {1, 2, 3, -1, -2, -3, 5, 4, 3, 11};
int suma = 0;
for (auto i = 0; i < 10; i++) {
suma += tablica[i];
}
cout << "Suma wszystkich elementów: " << suma << endl;
return 0;
}