M
Michael
Hi,
1. Could you please show me how to get the following print out in a
better way? If the number go to 100!
#include <iostream>
int main()
{
int a,b,c;
for (a=1; a<=3; a++)
for (b=1; b<=3; b++)
for (c=1; c<3; c++)
{
if ((a!=b) && (b!=c))
cout<<a<<' '<<b<<' '<<c<<endl;
}
return 0;
}
1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1
2. And, how to do a loop like a=5, 3, 7, 1, which is not continuous? I
need to use do while or while?
Thanks,
Michael
1. Could you please show me how to get the following print out in a
better way? If the number go to 100!
#include <iostream>
int main()
{
int a,b,c;
for (a=1; a<=3; a++)
for (b=1; b<=3; b++)
for (c=1; c<3; c++)
{
if ((a!=b) && (b!=c))
cout<<a<<' '<<b<<' '<<c<<endl;
}
return 0;
}
1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1
2. And, how to do a loop like a=5, 3, 7, 1, which is not continuous? I
need to use do while or while?
Thanks,
Michael