#include <iostream>using namespace Std;class fract{int n;int d;public:fract (): N (0), D (1) {}; Fract (int an,int AD): N (an), d (AD) {reduce ();} void reduce () {if (n<0) {d=-d;n=-n;} if (d==0) {cout<< "d==0!" <<endl;} int absn=n<0?-n:n;for (int i=d;i>1;i--) {if (n%i==0&&d%i==0) N/=i,d/=i;break;}} void Show () {cout<<n<< '/' <<d<<endl;} Double value () {return (double) n/d;}}; Class Dai:public Fract{int I;public:dai (): I (0) {}dai (int ai,int an,int AD): I (AI), Fract (An,ad) {}void Show () {cout< <i<< ' ('; Fract::show ();} Double value () {return i+fract::value ();}}; int main () {Dai D1;dai D2 (2,12,16);d 1.show ();cout<< "d1=" <<d1.value () <<endl;d2.show ();cout< < "d2=" <<d2.value () <<endl;cout<< "=================================" <<endl; Fract F1 (12,16); Fract f2;f1.show ();cout<< "f1=" <<f1.value () <<endl;f2.show ();cout<< "f2=" <<f2.value ( ) <<endl;}
Numerator of the "C + + program" score