C 程式設計題

2021-07-24 07:57:29 字數 1605 閱讀 3338

1樓:匿名使用者

#include

#include

#include

class number

;number::number(int m,int n)void number::zhuanhuan(int g,int h)

if(t)

else

if(fenzi==0)

cout<<"0"<>o;

if(o=='n'||o=='n') break;

else

<<"輸入錯誤!請輸入y進入或者n退出"<>a>>b>>c>>d;

number a1(a,b),a2(c,d),a3; //(a,b)表示分數a/b

cout<<"您輸入的有理數a1為: ";

cout<<"a1=";a1.show();

cout<<"化簡後的有理數a1為 a1=:";

a1.yuefen(a,b);

cout<<"a1轉化為實數後的數為 a1=";

a1.zhuanhuan(a,b);

cout<>p;

switch(p)

}試試這個

2樓:因為複雜

度#include

class fraction

friend void add(const fraction & a,const fraction & b); //兩分數相加

friend void sub(const fraction & a,const fraction & b); //本分數減去實參分數

riend void mul(const fraction & a,const fraction & b); //兩分數相乘

friend void div(const fraction & a,const fraction & b); //本分數除以實參分數

求倒數

friend bool epual(const fraction& a,const fraction& b); //等於運算

friend bool greaterthan(const fraction & a,const fraction & b); //大於運算

friend bool lessthan(const fraction & a,const fraction & b); //小於運算

fraction(fraction & c) //複製建構函式

}; void reduction(fraction & x) //把x化為最簡分數/求x的分子和分母的最大公約數

//化簡x,使分子分母縮小n倍

if(n!=1)

//若分母為負則讓分子分母同時取負後使分子分母轉換為正值

if(x.below<0)

cout<0)

class complex

complex operator+(complex);

complex(complex &com)

void print1()

看看 也許對你有用 呵呵

C程序的程式設計題,C程式的程式設計題

include include include define n 90 define m 50 char fun1 char s1,char s2 char fun2 char s1,char s2 void main 以下兩種演算法都可以 均編譯通過執行得到了正確結果 在執行其中乙個時,先把另乙個...

c語言程式設計題急,C語言程式設計題,急求!!!!

包含命令拼錯了 直接把演算法寫到輸出那裡 定義的float型別,記得scanf的時候是 f,不是 d include main include main 你把scanf語句放前面試試啊,程式如下 includes main 程式自己寫吧,對提高你的能力有幫助.思路 先用三個變數a bc存輸出 再根據...

C語言程式設計題

include double fact int n return double f double mypow double x,int n return m int main void 這個題的要求太惡搞了,出題的人程式設計水平真不敢恭維 f x 1 x x 襲2 2 x 3 3 x n n 直 到...