導游資格《導游實務》章節(jié)筆記:旅游保險
1. 如何判斷一段程序是由C 編譯程序還是由C++編譯程序編譯的?

答案:
#ifdef __cplusplus
cout<<"c++";
#else
cout<<"c";
#endif
2.文件中有一組整數(shù),要求排序后輸出到另一個文件中
答案:
#i nclude<iostream>
#i nclude<fstream>
using namespace std;
void Order(vector<int>& data) /pic/p>
{
int count = data.size() ;
int tag = false ; /pic/p>
for ( int i = 0 ; i < count ; i++)
{
for ( int j = 0 ; j < count - i - 1 ; j++)
{
if ( data[j] > data[j+1])
{
tag = true ;
int temp = data[j] ;
data[j] = data[j+1] ;
data[j+1] = temp ;
}
}
if ( !tag )
break ;
}
}
void main( void )
{
vector<int>data;
ifstream in("c:\\data.txt");
if ( !in)
{
cout<<"file error!";
exit(1);
}
int temp;
while (!in.eof())
{
in>>temp;
data.push_back(temp);
}
in.close(); /pic/p>
Order(data);
ofstream out("c:\\result.txt");
if ( !out)
{
cout<<"file error!";
exit(1);
}
for ( i = 0 ; i < data.size() ; i++)
out<<data[i]<<" ";
out.close(); /pic/p>
}
【導游資格《導游實務》章節(jié)筆記:旅游保險】相關文章:
導游證實務章節(jié)習題及答案02-11
導游資格證《導游實務》基礎試題11-24
導游資格證《導游實務》基礎試題04-13
導游資格考試《導游實務》考前沖刺試題02-03
2017導游資格證考試導游服務能力章節(jié)資料02-13
導游資格考試《導游實務》判斷題模擬03-23
- 相關推薦