本文整理汇总了C++中settings::setBase方法的典型用法代码示例。如果您正苦于以下问题:C++ settings::setBase方法的具体用法?C++ settings::setBase怎么用?C++ settings::setBase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类settings
的用法示例。
在下文中一共展示了settings::setBase方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: modifySettings
void modifySettings(settings &user)
{
cout << endl;
string setI;
string setS;
bool invalid=false;
int intSet=0;
do
{
intSet=0;
invalid=false;
setI.clear();
cout << "Enter desired precision: ";
std::getline(cin, setI);
for (int i=0; i<setI.size(); i++)
{
int target = setI.size()-i-1;
if (checkNumber(setI[target]) < 0 || checkNumber(setI[target]) > 9)
{
cout << "Invalid entry" << endl << endl;
invalid=true;
break;
}
else intSet += (checkNumber(setI[target]) * pow(10, i));
}
if (invalid==false)
{
if (intSet>PRECISION)
{
cout << "Invalid entry (precision must be between 0 and " << PRECISION << ")" << endl << endl;
invalid=true;
}
else
{
user.setRound(intSet);
}
}
} while (invalid==true);
do
{
intSet=0;
invalid=false;
setI.clear();
cout << "Enter desired base: ";
std::getline(cin, setI);
for (int i=0; i<setI.size(); i++)
{
int target = setI.size()-i-1;
if (checkNumber(setI[target]) < 0 || checkNumber(setI[target]) > 9 )
{
cout << "Invalid entry" << endl << endl;
invalid=true;
break;
}
else intSet += (checkNumber(setI[target]) * pow(10, i));
}
if (invalid==false)
{
if (intSet < 2 || intSet > 36)
{
cout << "Invalid entry (base must be between 2 and 36)" << endl << endl;
invalid=true;
}
else
{
user.setBase(intSet);
}
}
} while (invalid==true);
for (;;)
{
if (user.getPercent())
{
setS.clear();
cout << "Turn off percentages? ";
std::getline(cin, setS);
if (setS=="yes" || setS=="y")
{
user.percentOff();
break;
}
//.........这里部分代码省略.........
示例2: changeBase
bool changeBase(string &c, settings &user)
{
if (c == "base 2" || c == "base2" || c == "binary")
{
user.setBase(2);
return true;
}
if (c == "base 3" || c == "base3" || c == "ternary")
{
user.setBase(3);
return true;
}
if (c == "base 4" || c == "base4" || c == "quaternary")
{
user.setBase(4);
return true;
}
if (c == "base 5" || c == "base5" || c == "quinary")
{
user.setBase(5);
return true;
}
if (c == "base 6" || c == "base6" || c == "senary")
{
user.setBase(6);
return true;
}
if (c == "base 7" || c == "base7" || c == "septenary")
{
user.setBase(7);
return true;
}
if (c == "base 8" || c == "base8" || c == "octonary")
{
user.setBase(8);
return true;
}
if (c == "base 9" || c == "base9" || c == "nonary")
{
user.setBase(9);
return true;
}
if (c == "base 10" || c == "base10" || c == "decimal")
{
user.setBase(10);
return true;
}
if (c == "base 11" || c == "base11" || c == "undenary")
{
user.setBase(11);
return true;
}
if (c == "base 12" || c == "base12" || c == "dozenal" || c == "duodecimal")
{
user.setBase(12);
return true;
}
if (c == "base 13" || c == "base13" || c == "tridecimal")
{
user.setBase(13);
return true;
}
if (c == "base 14" || c == "base14" || c == "quattuordecimal")
{
user.setBase(14);
return true;
}
if (c == "base 15" || c == "base15" || c == "quindecimal")
{
user.setBase(15);
return true;
}
if (c == "base 16" || c == "base16" || c == "sexadecimal" || c == "hexadecimal")
{
user.setBase(16);
return true;
}
if (c == "base 17" || c == "base17" || c == "septendecimal")
{
user.setBase(17);
return true;
}
if (c == "base 18" || c == "base18" || c == "octodecimal")
{
//.........这里部分代码省略.........