 
 
 
 
 
 
 
  
これは GCC 拡張であって、 規格外なのかも知れないけれど、 printf() 互換のform() メンバー関数がある。
| testformat2.C | 
| #include <iostream.h>
void print()
{
  int i;
  double x1, x2;
  x1 = x2 = 1;
  for (i = 1; i <= 30; i++) {
    cout.form("%f %e %g", x1, x1, x1);
    cout.form("%f %e %g", x2, x2, x2);
    cout << endl;
    x1 *= 2; x2 /= 2;
  }
}
int main()
{
  print(); 
}
 | 
 
 
 
 
 
 
