c++_demo2_制表符的使用

  • 格式:wps
  • 大小:39.50 KB
  • 文档页数:2

/*demo7---P43 自测题14

写一个小程序,使用制表符转义序列\t来对齐不同的列。

制表符相当于打字机上的一个机械跳格位置,会导致输出从下一列开始,两列间距通常是8

个空格的倍数。

许多编辑器和大多数数字处理程序都允许调整制表位。我们的输出不调整*/

int main()

{

double one,two,three,four,five;

cout.setf(ios::fixed);

cout.setf(ios::showpoint);

cout.precision(3);

one=1; two=1.414;

three=1.732; four=2;

five=2.236;

cout<<"N"<<"\t"<<"Square Root"<<"\n"

<<"one"<<"\t"<

<<"two"<<"\t"<

<<"three"<<"\t"<

<<"four"<<"\t"<

<<"five"<<"\t"<

return 0;

}

结果:

/*demo6---P43 自测题13

写一个输出语句来输出一个换行符和一个制表符

int main()

{

cout<<"换行符是"<<"\n"

<<"制表符是"<<"\t";

return 0;

}*/ //demo6

结果