Language
C++
Compiler
gcc 12.1.0
Options
Warnings
Optimization
Don't Use Boost
Compiler Default
no pedantic
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> nums;
int elm, store, value, i, j;
cin >> elm;
for (int i = 0; i < elm; i++) {
cin >> value;
nums.push_back(value);
}
for (i = 0; i < elm; i++) {
store = 1;
for (j = 0; j < elm; j++) {
if (i==j) continue;
else store *= nums[j];
}
nums[i] = store; // Not able to assign
}
for (i = 0; i < elm; i++) cout << nums[i] << " ";
return 0;
}
5 1 2 3 4 5
$ g++ prog.cc -Wall -Wextra -I/opt/wandbox/boost-1.79.0-gcc-12.1.0/include -std=gnu++2b
120 7200 17280000 -1226571776 0
Exit Code:
0