Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int n, bazowa{ 4 }, i{ 1 };
- long long iloczyn{ 1 };
- cout << "Podaj ile liczb chcesz wymnozyc: ";
- cin >> n;
- while (i <= n) {
- /*int liczba;
- if (i % 2 == 0) {
- liczba = -bazowa;
- }
- else {
- liczba = bazowa;
- }*/
- int liczba{ i % 2 == 0 ? -bazowa : bazowa };
- iloczyn *= liczba; // iloczyn = iloczyn * liczba;
- ++i;
- bazowa += 4;
- }
- cout << "Iloczyn wszystkich liczb wynosi " << iloczyn << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement