0
if (ch1 = 'l' || 'L')
cout << left;
else if (ch1 = 'r' || 'R')
cout << right;
else
cout << "error" << endl;
cout << setw(++aw) << setfill(char(a)) << s1 << endl;
if (ch2 = 'l' || 'L')
cout << left;
else if (ch2 = 'r' || 'R')
cout << right;
else
cout << "error" << endl;
cout << setw(++bw) << setfill(char(b)) << s2 << endl;
if (ch3 = 'l' || 'L')
cout << left;
else if (ch3 = 'r' || 'R')
cout << right;
else
cout << "error" << endl;
cout << setw(++cw) << setfill(char(c)) << s3 << endl;
return 0;
}
我不完全確定爲什麼,但所有3個輸出行出來左對齊。如果有一個邏輯錯誤的地方,似乎合法的我,我還不能肯定還是我剛纔輸入它錯理由不能正常工作
'then'不是C++關鍵字... –
你需要學習一些基本的C++,包括什麼是*文字*值,像字符文字''L''。另外,如何在AND或OR鏈中使用多個條件。 –
我們可以看看'ch1','left'和'right'的聲明嗎? – scones