Task: | Ohjelma |
Sender: | Senpai |
Submission time: | 2017-01-19 13:29:34 +0200 |
Language: | C++ |
Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:16:4: error: expected '(' before 'else' if else(n%2==1 && n-3!<1){n=n-3; ^ input/code.cpp:18:1: error: 'else' without a previous 'if' else{cout<<0; ^ input/code.cpp:22:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i=0; i<v.size(); i++{ ^ input/code.cpp:22:29: error: expected ')' before '{' token for(int i=0; i<v.size(); i++{ ^
Code
#include <bits/stdc++.h>using namespace std;int n,k,x;vector<int>v;vector<string>m;int main(){cin>>n;vector<string>m(3);m[0]="ADD";m[1]="MUL";m[2]="END";while(n>1){if(n%2==0){n/=2;v.push_back(0);}if else(n%2==1 && n-3!<1){n=n-3;v.push_back(1);}else{cout<<0;return 0;}}cout<<v.size()<<"\n";for(int i=0; i<v.size(); i++{cout<<m[i]<<"\n";}}