注册 登录
编程论坛 C++教室

为什么书上的示范程序在Dev-C++4,9,9,2上运行不了呢,求指教

xiuzhexin 发布于 2012-03-02 19:43, 464 次点击
#include<iostream>
using namespace std;
int main()
{
    int number_of_pods,peas_per_pod,total_peas;
    cout<<"Press return after entering a number./n";
    cout<<Enter the number of pods:/n";
    cin>>number_of_pods;
    cout<<"Enter the number of peas in a pod:/n";
    cin>>peas_of_pods;
    total_peas=number_of_pods*peas_of_pod;
    cout<<"If you have";
    cout<<number_of_pods;
    cout<<"pea pods/n";
    cout<<"and";
    cout<<peas_of_pod;
    cout<<"peas in each pod,then/n";
    cout<<"you have";
    cout<<total_peas;
    cout<<"peas in all the pods./n";
    return 0
}


代码如上 谢谢。。 我是新手 分少给点了。。
2 回复
#2
yuccn2012-03-03 08:37
编译都不会通过 别说运行

最后一个return 你确定有分号吗?
#3
RegKiller2012-03-03 08:39
#include<iostream>
using namespace std ;
int main()
{
    int number_of_pods,peas_of_pods,total_peas ;
    cout<<"Press return after entering a number.\n" ;
    cout<<"Enter the number of pods :\n ";
    cin>>number_of_pods ;
    cout<<"Enter the number of peas in a pod:\n" ;
    cin>>peas_of_pods ;
    total_peas=number_of_pods*peas_of_pods ;
    cout<<"If you have" ;
    cout<<number_of_pods ;
    cout<<"pea pods\n" ;
    cout<<"and" ;
    cout<<"peas_of_pod" ;
    cout<<"peas in each pod,then\n" ;
    cout<<"you have" ;
    cout<<total_peas ;
    cout<<"peas in all the pods.\n" ;
    return 0 ;
}
1