65,211
社区成员
发帖
与我相关
我的任务
分享
int main() {
float fDecpounds = 0;
float fDecfrac = 0;
int nPounds = 0, nShillings = 0, nPence = 0;
cout << "Enter decimal pounds: ";
cin >> fDecpounds;
nPounds = (int) (fDecpounds);
fDecfrac = fDecpounds - nPounds;
nShillings = (int) (fDecfrac * 20);
fDecfrac = fDecfrac * 20 - nShillings;
nPence = (int) (fDecfrac * 12);
cout << "Equivalent in old notation: £" << nPounds << "." << nShillings
<< "." << nPence << endl;
return 0;
//============================================================================
// Name : cast.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
using namespace std;
int main() {
float fDecpounds = 0;
float fDecfrac = 0;
int nPounds = 0, nShillings = 0, nPence = 0;
cout << "Enter decimal pounds: ";
cin >> fDecpounds;
nPounds = (int) (fDecpounds);
fDecfrac = fDecpounds - nPounds;
nShillings = (int) (fDecfrac * 20);
fDecfrac = fDecfrac * 20 - nShillings;
nPence = (int) (fDecfrac * 12);
cout << "Equivalent in old notation: £" << nPounds << "." << nShillings
<< "." << nPence << endl;
return 0;
}