2014-09-21 24 views
2

正常工作,有什么错我的代码。运输及工务局局长()不是,我有我的代码不知道是否是一个错误或问题我的代码

#include <iostream> 
#include <iomanip> 
using namespace std; 

int main() 
{ 
cout << setfill('*') << setw(80) << "*"; 
cout << setw(21) << "Mt.Pleasant Official Billing Statement" << endl; 
cout << setfill('*') << setw(80) << "*" << endl; 
return 0; 
} 

添加人工空间的作品,但我想以编程方式添加的空间,但是当我测试这个是什么样子的应用:

enter image description here

+1

它的工作它究竟应该如何。如果你特别想要21个额外​​的空间或东西,把它们放进去。 – chris 2014-09-21 06:45:28

回答

3

setw移动文本,但设置最小宽度应采取

要达到什么样的,你必须记住,你应该有一个更大的价值实验,因为你的字符串为L例如21个字符,例如

cout << setfill('*') << setw(80) << "*" << endl; 
cout << setfill(' ') << setw(56) << "Mt.Pleasant Official Billing Statement" << endl; 
cout << setfill('*') << setw(80) << "*" << endl; 

输出:

******************************************************************************** 
        Mt.Pleasant Official Billing Statement 
******************************************************************************** 
+0

谢谢你现在它的作品:)吸取经验教训 – 2014-09-21 06:56:44

+0

补充:)谢谢 – 2014-09-21 06:58:44

相关问题