正在加载图片...
C++语言程序设计 清华大学郑莉 例11-2使用setw指定宽度 输 #include <iostream> #include<iomanip)》 出 #include <string> 流 using namespace std; int main({ doub1eva1ues[]={1.23,35.36,653.7,4358.24}; string names[]={"Zoot”,"Jimy,"A1”, "Stan"} for (int i 0;i 4;i++) 输出结果: cout <setw(6)<<names[i] Zoot 1.23 <setw(10)<<values[i]<endl; Jimmy 35.36 return 0; A1 653.7 Stan4358.24 10C++语言程序设计 清华大学 郑莉 10 例11-2使用setw指定宽度 #include <iostream> #include <iomanip> #include <string> using namespace std; int main() { double values[] = { 1.23, 35.36, 653.7, 4358.24 }; string names[] = { "Zoot", "Jimmy", "Al", "Stan" }; for (int i = 0; i < 4; i++) cout << setw(6) << names[i] << setw(10) << values[i] << endl; return 0; } 输 出 流 输出结果: Zoot 1.23 Jimmy 35.36 Al 653.7 Stan 4358.24
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有