Dec 22, 2015 at 1:56pm UTC
It is supposed to output permissions based off of a binary or sinlge digit code they enter.
#include <string>
#include <iostream>
#include <cstdlib>
using namespace std;
int main ()
{
int ipt1, ipt2, ipt3, prms1, prms2, prms3, opt1, opt2, opt3;
string none, r, w, x, rw, wx, rwk;
cin >> ipt1;
cin >> ipt2;
cin >> ipt3;
if (ipt1 = 1)
{
prms1 = 'x';
opt1 = 001;
}
else if (ipt1 = 2)
{
prms1 = 'w';
opt1 = 010;
}
else if (ipt1 = 3)
{
prms1= 'wx';
opt1 = 011;
}
else if (ipt1 = 4)
{
prms1 = 'r';
opt1 = 100;
}
else if (ipt1 = 5)
{
prms1 = 'rx';
opt1= 101;
}
else if (ipt1 = 6)
{
prms1 ='rw';
opt1 = 110;
}
else if (ipt1 = 7)
{
prms1 = 'rwk';
opt1 = 111;
}
else if (ipt1 = 0)
{
prms1 = 'none';
opt1 = 000;
}
if (ipt2 = 1)
{
prms2 = 'x';
opt2 = 001;
}
else if (ipt2 = 2)
{
prms2 = 'w';
opt2 = 010;
}
else if (ipt2 = 3)
{
prms2= 'wx';
opt2 = 011;
}
else if (ipt2 = 4)
{
prms2 = 'r';
opt2 = 100;
}
else if (ipt2 = 5)
{
prms2 = 'rx';
opt2= 101;
}
else if (ipt2 = 6)
{
prms2 ='rw';
opt2 = 110;
}
else if (ipt2 = 7)
{
prms2 = 'rwk';
opt2 = 111;
}
else if (ipt2 = 0)
{
prms2 = 'none';
opt2 = 000;
}
if (ipt3 = 1)
{
prms3 = 'x';
opt3 = 001;
}
else if (ipt3 = 2)
{
prms3 = 'w';
opt3 = 010;
}
else if (ipt3 = 3)
{
prms3= 'wx';
opt3 = 011;
}
else if (ipt3 = 4)
{
prms3 = 'r';
opt3 = 100;
}
else if (ipt3 = 5)
{
prms3= 'rx';
opt3= 101;
}
else if (ipt3 = 6)
{
prms3 ='rw';
opt3 = 110;
}
else if (ipt3 = 7)
{
prms3 = 'rwk';
opt3 = 111;
}
else if (ipt3 = 0)
{
prms3 = 'none';
opt3 = 000;
}
if (ipt1= 001)
{
prms1 = 'x';
opt1= 1;
}
else if (ipt1 = 010)
{
prms1 = 'w';
opt1 = 2;
}
else if (ipt1 = 011)
{
prms1= 'wx';
opt1 = 3;
}
else if (ipt1 = 100)
{
prms1 = 'r';
opt1 = 4;
}
else if (ipt1 = 101)
{
prms1 = 'rx';
opt1= 5;
}
else if (ipt1 = 110)
{
prms1 ='rw';
opt1 = 6;
}
else if (ipt1 = 111)
{
prms1 = 'rwk';
opt1 = 7;
}
else if (ipt1 = 000)
{
prms1 = 'none';
opt1 = 0;
}
if (ipt2 = 001)
{
prms2 = 'x';
opt2 = 1;
}
else if (ipt2= 010)
{
prms2 = 'w';
opt2 = 2;
}
else if (ipt2 = 011)
{
prms2= 'wx';
opt2 = 3;
}
else if (ipt2 = 100)
{
prms2 = 'r';
opt2 = 4;
}
else if (ipt2 = 101)
{
prms2 = 'rx';
opt2= 5;
}
else if (ipt2 = 110)
{
prms2 ='rw';
opt2 = 6;
}
else if (ipt2 = 111)
{
prms2 = 'rwk';
opt2 = 7;
}
else if (ipt2 = 000)
{
prms2 = 'none';
opt2 = 0;
}
if (ipt3 = 001)
{
prms3 = 'x';
opt3 = 1;
}
else if (ipt3 = 010)
{
prms3 = 'w';
opt3 = 2;
}
else if (ipt3 = 011)
{
prms3= 'wx';
opt3 = 3;
}
else if (ipt3 = 100)
{
prms3 = 'r';
opt3 = 4 ;
}
else if (ipt3 = 101)
{
prms3 = 'rx';
opt3= 5;
}
else if (ipt3 = 110)
{
prms3 ='rw';
opt3 = 6;
}
else if (ipt3 = 111)
{
prms3 = 'rwk';
opt3 = 7;
}
else if (ipt3 = 000)
{
prms3 = 'none';
opt3 = 0;
}
cout << prms1 << endl;
cout << prms2 << endl;
cout << prms3 << endl;
}
Dec 22, 2015 at 2:52pm UTC
in each condition, use "==" for equal test
"=" means assignment