书籍名称:C++ Primer Plus(中文第五版)
错误说明:
1.第13行缺少cout<<或第12行多了个;
2.程序运行后的输入应为184,非177
- //modulus.cpp -- uses % operator to convert lbs to stone
- #include <iostream>
- int main()
- {
- using namespace std;
- const int lbs_per_stn=14;
- int lbs;
- cout<<"Enter your weight in pounds:";
- cin>>lbs;
- int stone=lbs/lbs_per_stn; //whole stone
- int pounds=lbs%lbs_per_stn; //remainder in pounds
- cout<<lbs<<" pounds are "<< stone;
- <<" stone,"<<pounds<<" pounds./n";
- system("pause");
- return 0;
- }