| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 998 人关注过本帖
标题:编译不通过不知哪里出了问题 请大佬们请指点迷津
只看楼主 加入收藏
风流泰
Rank: 1
等 级:新手上路
帖 子:78
专家分:0
注 册:2018-9-29
结帖率:87.88%
收藏
已结贴  问题点数:6 回复次数:1 
编译不通过不知哪里出了问题 请大佬们请指点迷津
//编写程序获取vector容器的第一个元素,分别使用下标操作符,front函数以及begin函数实现该功能,并提供空的vector容器测试你的程序
#include<iostream>
#include<vector>
using namespace std;
int main(void)
{
    cout<<"\tInput some int numbers to a vector(Ctrl+Z to end):"<<endl;
    vector<int> ivec;
    int i;
    while(cin>>i)
    {
        ivec.push_back(i);
    }
    if(!ivec.empty())
    {
        cout<<"The first elements of the vector is:";
        cout<<"\n\t==>>Using front():\t"<<ivec.front();
        cout<<"\n\t==>>Using begin():\t"<<ivec.begin();
        cout<<"\n\t==>>Using ivec[0]:\t"<<ivec[0];
        cout<<"\n\t==>>Using ivec.at(0):\t"<<ivec.at(0)<<endl;
    }
    system("pause");
    return 0;
}
搜索更多相关主题的帖子: 编译 vector using int cout 
2019-04-18 13:44
ZJYTY
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:4
帖 子:92
专家分:700
注 册:2018-12-20
收藏
得分:6 
程序代码:
#include<iostream>
#include<vector>
using namespace std;
int main(void)
{
    cout << "\tInput some int numbers to a vector(Ctrl+Z to end):" << endl;
    vector<int> ivec;
    int i;
    while (cin >> i)
    {
        ivec.push_back(i);
    }
    if (!ivec.empty())
    {
        cout << "The first elements of the vector is:";
        cout << "\n\t==>>Using front():\t" << ivec.front();
        cout << "\n\t==>>Using begin():\t" << *(ivec.begin());
        cout << "\n\t==>>Using ivec[0]:\t" << ivec[0];
        cout << "\n\t==>>Using ivec.at(0):\t" << ivec.at(0) << endl;
    }
    system("pause");
    return 0;
}

-------------------------------若有不当之处,敬请谅解-------------------------------
2019-04-18 13:56
快速回复:编译不通过不知哪里出了问题 请大佬们请指点迷津
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.067201 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved