-3

我想在“ABC”之前打印两个带有 5 个空格字符的字符串(比如“ABC”和“DEF”),并且第二个字符串将在第一个字符串开始后 7 个字符开始。

4

2 回答 2

2

我怀疑您正在寻找 width() 方法:

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

int main()
{
  string abc = "ABC";
  string edf = "EDF";
  cout.width(8);
  cout << abc;
  cout.width(7);
  cout << edf;
  return 0;
}
于 2010-03-14T18:53:43.833 回答
-1
#include <cstdio>
#include <cstdlib>
#include <iostream>

using namespace std;

int main() 
{ 
char a[] = "ABC";
char b[] = "EDF";
cout<"     "<<a<<"       "<<b;
return 0; 
}
于 2010-03-14T22:00:51.043 回答