不要在最后一个数字后打印空格 [英] Don't print space after last number
本文介绍了不要在最后一个数字后打印空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
LANGUAGE:C ++
您好,在以下函数(代码块)中,我已经写了一行来打印字符之间的空格,但我不想打印空格最后字符。我如何解决这个问题?
LANGUAGE: C++ Hello, in the following function (code block) i have written a line to print an space between characters but i don't want print spaces after last characters. How can i solve this problem?
bool perfecto(int n)
{
int suma, i;
suma = 0;
for (i = 1; i < n; i++)
{
if (n % i == 0)
{
suma += i;
cout << i << " ";
}
}
if (suma == n)
return true;
else
return false;
}
最好的问候。
ÁngelManuel。
Best regards. Ángel Manuel.
推荐答案
最简单的方法是解决问题:如果你只打印空格
The simplest way would be to turn the problem around: if you only print spaces before printing the number (and not after) then it becomes how not to print the first time, which is much easier.
我会让你明白:)
这篇关于不要在最后一个数字后打印空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文