i have tried to implement following code
#include <iostream>
#include <bitset>
using namespace std;
int main(){
//bitset<4>mybits;
//cout<<mybits<<endl;
int a[]={3,1,4,5,7,8};
int max=a[0];
int t=sizeof(a)/sizeof(a[0]);
for (int i=1;i<t;i++){
if (a[i]>max){
max=a[i];
}
}
bitset<max+1>mybits;
return 0;
}
but it says that max must have constant value what to do?here i know that maximum element is eight but imagine that we enter numbers from keyboard in this case maximum number is unknown thanks