C++ 输入一个长度不定的vector并打印
vector<int>a;intm=0;cout<<"输入整数"<<endl;while((m=getchar())!='\n'){a.push_back(m);}ffl...
vector<int> a;
int m = 0;
cout << "输入整数" << endl;
while ((m=getchar())!='\n')
{
a.push_back(m);
}
fflush(stdin);
int len1 = a.size();
for (int i = 0; i<len1; i++)
{
cout << a[i];
}
cout << endl;
sort(a.begin(), a.end());
a.erase(unique(a.begin(), a.end()), a.end());
for (int hhh = 0; hhh<a.size(); hhh++)
{
cout << a[hhh] << endl;}
输入(1,2,2,3),删除相等的元素并打印
打印结果是49325032503251
32
49
50
51
是哪里出错了? 展开
int m = 0;
cout << "输入整数" << endl;
while ((m=getchar())!='\n')
{
a.push_back(m);
}
fflush(stdin);
int len1 = a.size();
for (int i = 0; i<len1; i++)
{
cout << a[i];
}
cout << endl;
sort(a.begin(), a.end());
a.erase(unique(a.begin(), a.end()), a.end());
for (int hhh = 0; hhh<a.size(); hhh++)
{
cout << a[hhh] << endl;}
输入(1,2,2,3),删除相等的元素并打印
打印结果是49325032503251
32
49
50
51
是哪里出错了? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询