帮我找错误,,谢谢。我是C++初学者,把书上的代码输入编译器中,总是显示有一个错误,可是找不出来。
#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_per_pod;
total_peas=number_of_pods*peas_per_pod;
cout << "if you have";
cout << number_of_pods;
cout << "and";
cout << peas_per_pod;
cout << "peas in each pod,then\n";
cout << "you have";
cout << total_peas;
cout << "peas in all the pods.\n";
return 0;
}
直接复制你的程滚谈序编译 没发大激碰现问题
运行结果
press return after entering a number.
enter the number of pods:
3
enter the number of peas in a pod:
4
if you have3and4peas in each pod,then
you have12peas in all the pods.
你把错铅核误信息发上来看下
头文件前面加上#include"stdafx.h"
如这样,我这里行了。
#include"stdafx.h"
#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_per_pod;
total_peas=number_of_pods*peas_per_pod;
cout << "if you have";
cout << number_of_pods;
cout << "and";
cout << peas_per_pod;
cout << "peas in each pod,then\n";
cout << "you have";
cout << total_peas;
cout <毁启< "peas in all the pods.\n";
return 0;
}
把错误提示贴出来啊
我编译了一下,木有问题,你用的什么编译器?
你把提示信息也发上来