Question: //I have this code but when i compile it with g++ -std=c++11 -Wall -Werror -o lab lab.cpp I get several error. Mostly that I can't
//I have this code but when i compile it with g++ -std=c++11 -Wall -Werror -o lab lab.cpp I get several error. Mostly that I can't compare signed and unsigned integers. Could you see if you can fix it please.
#include
using namespace std;
class BITSET{ private: vector
string ToBinary(int val,int space){ BITSET b; int i = 0; while(val > 2){ if(val%2 == 0){ b.Clear(i); }else{ b.Set(i); } i++; val = val/2; }
if(val == 1){ b.Set(i); }
if(val == 2){ b.Clear(i); i++; b.Set(i); } string s = ""; for(int i = 32;i>0;i--){ if(i != 32 && i % space == 0){ s += ' '; } if(b.Test(i)){ s += '1'; }else{ s += '0'; } } cout<
int main(){ BITSET b; char command = ' '; while(command != 'q'){ printf(" CMD >> "); scanf("%c",&command); switch(command){ case 't': { int n; scanf("%d",&n); if(b.Test(n)){ printf(" 1"); }else{ printf(" 0"); } break; } case 's': { int n; scanf("%d",&n); b.Set(n); break; } case 'g': { int n; scanf("%d",&n); b.print(n); break; } case 'n': { int n = b.GetNumSets(); printf(" Number Of Set : %d",n); break; } case 'q': { command = 'q'; break; } case 'c': { int n; scanf("%d",&n); b.Clear(n); break; } default: printf(" INVALID COMMAND !!! "); } scanf("%*c",&command); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
