| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 556 人关注过本帖
标题:编好了程序不会运行,神了,求高手指点!!!!
取消只看楼主 加入收藏
枫落花残
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2012-9-27
结帖率:50%
收藏
已结贴  问题点数:20 回复次数:2 
编好了程序不会运行,神了,求高手指点!!!!
#include "stdafx.h"
#include <algorithm>
#include <iomanip>
#include <ios>
#include <iostream>
#include <string>
#include <vector>

using std::cin;             using std::sort;
using std::cout;            using std::streamsize;
using std::endl;            using std::string;
using std::setprecision;    using std::vector;

int main()
{
   
    cout << "Please enter your first name: ";
    string name;
    cin >> name;
    cout << "Hello, " << name << "!" << endl;

   
    cout << "Please enter your midterm and final exam grades: ";
    double midterm, final;
    cin >> midterm >> final;

   
    cout << "Enter all your homework grades, "
            "followed by end-of-file: ";

    vector<double> homework;
    double x;
    while (cin >> x)
        homework.push_back(x);

   
    typedef vector<double>::size_type vec_sz;
    vec_sz size = homework.size();
    if (size == 0) {
        cout << endl << "You must enter your grades.  "
                        "Please try again." << endl;   
        return 1;
    }

    sort(homework.begin(), homework.end());

   
    vec_sz mid = size/2;
    double median;
    median = size % 2 == 0 ? (homework[mid] + homework[mid-1]) / 2
                           : homework[mid];

   
    streamsize prec = cout.precision();
    cout << "Your final grade is " << setprecision(3)
         << 0.2 * midterm + 0.4 * final + 0.4 * median
         << setprecision(prec) << endl;

    return 0;
}

这个程序,我是按书上编的,但是不知道怎么运行,运行到第三步就不往下走了,求高手指点,我是新手,二专选的计算机,课本又是全英文的,实在费劲,求高手指点啊
另外说一下,我是文科生,之前没有任何编程基础,连C语言也不会,
搜索更多相关主题的帖子: include first 
2012-09-27 18:33
枫落花残
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2012-9-27
收藏
得分:0 
回复 2楼 qunxingw
可是,我是按课本上一步步来的啊,我都不知道怎么办了
2012-09-27 19:55
枫落花残
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2012-9-27
收藏
得分:0 
回复 5楼 qiaokangjun
你编译的时候出错了吗,应该没有吧,我是能编译成功的,就是不知道怎么运行
2012-09-29 12:22
快速回复:编好了程序不会运行,神了,求高手指点!!!!
数据加载中...
 
   



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

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