1,cout<<boolalpha<<(2>3)<<endl;输出什么?
Dev c++上输出false,VC++输出0,why?
2, 我机子上的VC6.0上编译通不过,可Dev C++可以运行,why?
#include
<
fstream
>
using namespace std;
int main()
{
ifstream in ( " F://data.txt " );
ofstream out ( " F://a.txt " );
for ( string str; getline( in , str); )
out << str << endl;
return 0 ;
}
using namespace std;
int main()
{
ifstream in ( " F://data.txt " );
ofstream out ( " F://a.txt " );
for ( string str; getline( in , str); )
out << str << endl;
return 0 ;
}
3 ,
#include
<
iostream
>
using namespace std;
void OutPutLine( int row)
{
int i;
for (i = 4 - row;i > 0 ;i -- )
cout << " " ;
for (i = 2 * row - 1 ;i > 0 ;i -- )
cout << " * " ;
cout << endl;
}
int main()
{
int i;
for (i = 1 ;i <= 4 ;i ++ )
OutPutLine(i);
for (i = 3 ;i >= 1 ;i -- )
OutPutLine(i);
return 0 ;
}
using namespace std;
void OutPutLine( int row)
{
int i;
for (i = 4 - row;i > 0 ;i -- )
cout << " " ;
for (i = 2 * row - 1 ;i > 0 ;i -- )
cout << " * " ;
cout << endl;
}
int main()
{
int i;
for (i = 1 ;i <= 4 ;i ++ )
OutPutLine(i);
for (i = 3 ;i >= 1 ;i -- )
OutPutLine(i);
return 0 ;
}
4 ,
#include
<
iostream
>
using namespace std;
void OutPutLine( int row)
{
int i;
for (i = 1 ;i <= row - 1 ;i ++ )
{
cout << " " ;
}
for (i = 1 ;i <= 21 - 2 * row;i ++ )
{
cout << " M " ;
}
cout << endl;
}
int main()
{
for ( int i = 1 ;i <= 10 ;i ++ )
{
OutPutLine(i);
}
return 0 ;
}
5
,
using namespace std;
void OutPutLine( int row)
{
int i;
for (i = 1 ;i <= row - 1 ;i ++ )
{
cout << " " ;
}
for (i = 1 ;i <= 21 - 2 * row;i ++ )
{
cout << " M " ;
}
cout << endl;
}
int main()
{
for ( int i = 1 ;i <= 10 ;i ++ )
{
OutPutLine(i);
}
return 0 ;
}
#include
<
iostream
>
using namespace std;
void OutPutLine( int row)
{
int i;
char ch = ' A ' ;
for (i = 1 ;i <= 10 - row;i ++ )
{
cout << " " ;
}
for (i = 1 ;i <= 2 * row - 1 ;i ++ )
{
cout << ch;
ch ++ ;
}
cout << endl;
}
int main()
{
for ( int i = 1 ;i <= 10 ;i ++ )
{
OutPutLine(i);
}
return 0 ;
}
6
,
using namespace std;
void OutPutLine( int row)
{
int i;
char ch = ' A ' ;
for (i = 1 ;i <= 10 - row;i ++ )
{
cout << " " ;
}
for (i = 1 ;i <= 2 * row - 1 ;i ++ )
{
cout << ch;
ch ++ ;
}
cout << endl;
}
int main()
{
for ( int i = 1 ;i <= 10 ;i ++ )
{
OutPutLine(i);
}
return 0 ;
}
/*
筛法求素数
*/
#include < iostream >
#include < vector >
using namespace std;
const int LEN = 101 ;
vector < int > b(LEN, 1 );
void ShaiSu()
{
int i,j;
for (i = 2 ;i < LEN;i ++ )
{
if (b[i] == 1 )
{
for (j = 2 ;i * j < LEN;j ++ )
{
b[i * j] = 0 ;
}
}
}
}
void OutPut()
{
int i;
for (i = 2 ;i < len;i ++ )
{
if (b[i] == 1 )
{
cout << i << " 是素数 " << endl;
}
}
}
int main()
{
ShaiSu();
OutPut();
return 0 ;
}
#include < iostream >
#include < vector >
using namespace std;
const int LEN = 101 ;
vector < int > b(LEN, 1 );
void ShaiSu()
{
int i,j;
for (i = 2 ;i < LEN;i ++ )
{
if (b[i] == 1 )
{
for (j = 2 ;i * j < LEN;j ++ )
{
b[i * j] = 0 ;
}
}
}
}
void OutPut()
{
int i;
for (i = 2 ;i < len;i ++ )
{
if (b[i] == 1 )
{
cout << i << " 是素数 " << endl;
}
}
}
int main()
{
ShaiSu();
OutPut();
return 0 ;
}