I am trying to remove similar consecutive terms in a vector.Got an error inside if statement ,GNU GCC Compiler.
#include<bits/stdc++.h>
using namespace std;
int main(){int n;cin>>n;vector<int> a;int k;
for(int i=0;i<n;i++){cin>>k; a.push_back(k);
if(i>=1 && a[i]==[i-1]){a.pop_back();n-=1;}} //Error in this line.
return 0;}
Error:
Expected ',' before '-' token .
Aucun commentaire:
Enregistrer un commentaire