截图:
如果显示“2 + 1 + 3 +的总和为6”,我想在3之后摆脱最后的“+”符号,因为它显然看起来不太好。有没有人知道如何摆脱它?
提前谢谢!
cout << "The sum of ";
for (i = 1; i <= InputLimit; i++) // This loop shows all user entered 'elements' of the array
cout << numbers[i] << " + ";
cout << " is " << sum << ". ";
答案 0 :(得分:-1)
只需提出条件:
for (i = 0; i <= InputLimit; i++){ // This is just the loop to show the numbers with '+' or no.
if (i != InputLimit){
cout << numbers[i] << " + ";
}
else {
cout << numbers[i];
}
}
我希望它适合你XD