单项选择题(40min答完)
2.有如下一段代码:
#define func(x,y) x*y+x
void main { int a=2; int b=3; b+=b*func(a,b);cout<<b/4<<endl;}
运行结果为()
5
3
6
4
2
以上都不是
#define func(x,y) x*y+x
void main { int a=2; int b=3; b+=b*func(a,b);cout<<b/4<<endl;}
运行结果为()
5
3
6
4
2
以上都不是
4.下列代码的输出为:
#include <iostream>
#include <vector>
using namespace std;
int main(void)
{
vector<int> array;
array.push_back(100);
array.push_back(300);
array.push_back(300);
array.push_back(300);
array.push_back(300);
array.push_back(500);
vector<int>::iterator itor;
for(itor=array.begin();itor!=array.end();itor++)
{
if(*itor==300)
{
itor = array.erase(itor);
}
}
for(itor=array.begin();itor!=array.end();itor++)
{
cout<<*itor<<" ";
}
return 0;
}
100 300 300 300 300 500
#include <iostream>
#include <vector>
using namespace std;
int main(void)
{
vector<int> array;
array.push_back(100);
array.push_back(300);
array.push_back(300);
array.push_back(300);
array.push_back(300);
array.push_back(500);
vector<int>::iterator itor;
for(itor=array.begin();itor!=array.end();itor++)
{
if(*itor==300)
{
itor = array.erase(itor);
}
}
for(itor=array.begin();itor!=array.end();itor++)
{
cout<<*itor<<" ";
}
return 0;
}
100 300 300 300 300 500