C++ 我的while循环不会开始,即使它是真正的C++;
我的代码不想读取注释之间的内容,只是跳过它,即使phone和snn设置为小于代码内部的值C++ 我的while循环不会开始,即使它是真正的C++;,c++,while-loop,C++,While Loop,我的代码不想读取注释之间的内容,只是跳过它,即使phone和snn设置为小于代码内部的值 int num = 1; while (num > 0 && num < 2) { num = 1; string first = "chicken"; string last = "salad"; string full = "chicken salad"; int pho
int num = 1;
while (num > 0 && num < 2) {
num = 1;
string first = "chicken";
string last = "salad";
string full = "chicken salad";
int phone = 1;
int snn = 1;
cout << "enter your first name: ";
cin >> first;
cout << "enter your last name: ";
cin >> last;
full = first + " " + last;
cout << phone;
// works all the way to here then doesnt read the while
while (phone < 1000000000 && phone > 9999999999) {
cout << "enter 10 digit phone nmber (with no dashes or parenthesis): ";
cin >> phone;
}
while (snn < 100000000 && snn > 999999999) {
cout << "enter 9 digit snn <with no dashes>: ";
cin >> snn;
}
// starts working again here
cout << "\n\tT H A N K Y O U\n\n";
system("pause");
return 0;
}
int num=1;
而(num>0&&num<2){
num=1;
先串=“鸡肉”;
string last=“沙拉”;
string full=“鸡肉沙拉”;
int phone=1;
int snn=1;
cout>首先;
最后;
满=第一个+“”+最后一个;
cout 9999999){
电话;
}
而(snn<100000000&&snn>9999999){
cout>snn;
}
//在这里重新开始工作
cout在两个while循环中,您都有一个&
来代替|
,这意味着您要求手机
同时小于100000000
和大于9999999999999
,这将始终返回false
手机初始化为de>1
,使电话>9999999999
始终为假。对于snn
也一样。您的意思是或(|
)?如果你在调试器中一步一步地解决问题,你马上就会发现问题。<100000000和>99999999是什么数字?你需要|
来代替&&
。电话怎么可能<100000000和>99999999999?我完全忘记了| |命令谢谢你,我习惯把它放在数字里面请注意,99999999
可能大于INT\u MAX
(假设为32位整数)。