-3

「ABC」の前に5つの空白文字を含む2つの文字列(「ABC」と「DEF」など)を印刷し、2番目の文字列は最初の文字列の先頭から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 に答える