K
kerbcurb
Unregistered / Unconfirmed
GUEST, unregistred user!
#pragma argsused
#include <iostream>
#include <stdio.h>
#include <complex>
using namespace std;
int main()
{
int x;
std::cout <<"int"<<std::endl;
printf("/n i x 2x 3x/n");
printf("------------------------------------------------------------------/n");
for (int i= 1;
i < 12;
i++ )
{
x = i;
std::cout <<i<<' ';
printf(" %2d %d %d %d/n", i, x,2*x,3*x);
}
printf("/n------------------------------------------------------------------/n");
//std::cin.get();
std::cout <<"float"<<std::endl;
float y;
printf("/n i y 2y 3y/n");
printf("/n------------------------------------------------------------------/n");
for (int i= 1;
i < 12;
i++ )
{
y = i;
std::cout <<i<<' ';
printf(" %2d %f %f %f/n", i, y,2*y,3*y);
}
std::cout <<std::endl<<"double"<<std::endl;
do
uble z;
printf("/n i z 2z 3z/n");
printf("/n------------------------------------------------------------------/n");
for (int i= 1;
i < 12;
i++ )
{
z = i;
std::cout <<i<<' ';
printf(" %2d %f %f %f/n", i, z,2*z,3*z);
}
printf("/n------------------------------------------------------------------/n");
std::cout <<std::endl<<"complex"<<std::endl;
complex<double>w;
printf("/n i w 2w 3w/n");
printf("/n------------------------------------------------------------------/n");
for (int i= 1;
i < 12;
i++ )
{
w = complex<double>(i,i);
std::cout <<w<<' ';
}
printf("/n------------------------------------------------------------------/n");
std::cout<<"enter"<<std::endl;
return 0;
}
结果:
cbxexam5.exe
int
1 2 3 4 5 6 7 8 9 10 11
i x 2x 3x
------------------------------------------------------------------
1 1 2 3
2 2 4 6
3 3 6 9
4 4 8 12
5 5 10 15
6 6 12 18
7 7 14 21
8 8 16 24
9 9 18 27
10 10 20 30
11 11 22 33
float
1 2 3 4 5 6
------------------------------------------------------------------
i y 2y 3y
------------------------------------------------------------------
1 1.000000 2.000000 3.000000
2 2.000000 4.000000 6.000000
3 3.000000 6.000000 9.000000
4 4.000000 8.000000 12.000000
5 5.000000 10.000000 15.000000
7 8 9 10 11
double
1 2 6 6.000000 12.000000 18.000000
7 7.000000 14.000000 21.000000
8 8.000000 16.000000 24.000000
9 9.000000 18.000000 27.000000
10 10.000000 20.000000 30.000000
11 11.000000 22.000000 33.000000
i z 2z 3z
------------------------------------------------------------------
1 1.000000 2.000000 3.000000
3 4 5 6 7 8 9 10 11 2 2.000000 4.000000 6.000000
3 3.000000 6.000000 9.000000
4 4.000000 8.000000 12.000000
5 5.000000 10.000000 15.000000
6 6.000000 12.000000 18.000000
7 7.000000 14.000000 21.000000
8 8.000000 16.000000 24.000000
9 9.000000 18.000000 27.000000
10 10.000000 20.000000 30.000000
complex
(1,1) (2,2) (3,3) (4,4) (5,5) (6,6) (7,7) (8,8) (9,9) (10,10) (11,11) enter
11 11.000000 22.000000 33.000000
------------------------------------------------------------------
i w 2w 3w
------------------------------------------------------------------
------------------------------------------------------------------
但是:
这段程序用Dev-C++和C++Builder5编译运行输出结果的顺序和希望的一样,都没有问题
不知道顺序为什么有问题,而且随着类型的不同,结果也不同,是不是流类库特有的,哪位朋友知道,请告知,谢谢。
#include <iostream>
#include <stdio.h>
#include <complex>
using namespace std;
int main()
{
int x;
std::cout <<"int"<<std::endl;
printf("/n i x 2x 3x/n");
printf("------------------------------------------------------------------/n");
for (int i= 1;
i < 12;
i++ )
{
x = i;
std::cout <<i<<' ';
printf(" %2d %d %d %d/n", i, x,2*x,3*x);
}
printf("/n------------------------------------------------------------------/n");
//std::cin.get();
std::cout <<"float"<<std::endl;
float y;
printf("/n i y 2y 3y/n");
printf("/n------------------------------------------------------------------/n");
for (int i= 1;
i < 12;
i++ )
{
y = i;
std::cout <<i<<' ';
printf(" %2d %f %f %f/n", i, y,2*y,3*y);
}
std::cout <<std::endl<<"double"<<std::endl;
do
uble z;
printf("/n i z 2z 3z/n");
printf("/n------------------------------------------------------------------/n");
for (int i= 1;
i < 12;
i++ )
{
z = i;
std::cout <<i<<' ';
printf(" %2d %f %f %f/n", i, z,2*z,3*z);
}
printf("/n------------------------------------------------------------------/n");
std::cout <<std::endl<<"complex"<<std::endl;
complex<double>w;
printf("/n i w 2w 3w/n");
printf("/n------------------------------------------------------------------/n");
for (int i= 1;
i < 12;
i++ )
{
w = complex<double>(i,i);
std::cout <<w<<' ';
}
printf("/n------------------------------------------------------------------/n");
std::cout<<"enter"<<std::endl;
return 0;
}
结果:
cbxexam5.exe
int
1 2 3 4 5 6 7 8 9 10 11
i x 2x 3x
------------------------------------------------------------------
1 1 2 3
2 2 4 6
3 3 6 9
4 4 8 12
5 5 10 15
6 6 12 18
7 7 14 21
8 8 16 24
9 9 18 27
10 10 20 30
11 11 22 33
float
1 2 3 4 5 6
------------------------------------------------------------------
i y 2y 3y
------------------------------------------------------------------
1 1.000000 2.000000 3.000000
2 2.000000 4.000000 6.000000
3 3.000000 6.000000 9.000000
4 4.000000 8.000000 12.000000
5 5.000000 10.000000 15.000000
7 8 9 10 11
double
1 2 6 6.000000 12.000000 18.000000
7 7.000000 14.000000 21.000000
8 8.000000 16.000000 24.000000
9 9.000000 18.000000 27.000000
10 10.000000 20.000000 30.000000
11 11.000000 22.000000 33.000000
i z 2z 3z
------------------------------------------------------------------
1 1.000000 2.000000 3.000000
3 4 5 6 7 8 9 10 11 2 2.000000 4.000000 6.000000
3 3.000000 6.000000 9.000000
4 4.000000 8.000000 12.000000
5 5.000000 10.000000 15.000000
6 6.000000 12.000000 18.000000
7 7.000000 14.000000 21.000000
8 8.000000 16.000000 24.000000
9 9.000000 18.000000 27.000000
10 10.000000 20.000000 30.000000
complex
(1,1) (2,2) (3,3) (4,4) (5,5) (6,6) (7,7) (8,8) (9,9) (10,10) (11,11) enter
11 11.000000 22.000000 33.000000
------------------------------------------------------------------
i w 2w 3w
------------------------------------------------------------------
------------------------------------------------------------------
但是:
这段程序用Dev-C++和C++Builder5编译运行输出结果的顺序和希望的一样,都没有问题
不知道顺序为什么有问题,而且随着类型的不同,结果也不同,是不是流类库特有的,哪位朋友知道,请告知,谢谢。