Untitled
unknown
plain_text
5 months ago
945 B
3
Indexable
#include <iostream> using namespace std; int main() { long int par[5], impar[5]; int n, ocount = 0, ecount = 0; for (int i = 0; i < 15; i++) { cin >> n; if (n % 2 == 0) { par[ecount] = n; ecount++; } else { impar[ocount] = n; ocount++; } if (ecount == 5) { for (int j = 0; j < 5; j++) { cout << "par[" << j << "] = " << par[j] << endl; } ecount = 0; } if (ocount == 5) { for (int j = 0; j < 5; j++) { cout << "impar[" << j << "] = " << impar[j] << endl; } ocount = 0; } } for (int i = 0; i < ocount; i++) { cout << "impar[" << i << "] = " << impar[i] << endl; } for (int i = 0; i < ecount; i++) { cout << "par[" << i << "] = " << par[i] << endl; } return 0; }
Editor is loading...
Leave a Comment