|
#include <iostream.h><br/> class MaxMin8<br/> {<br/> private:<br/> int a,b,c,d,e,f,j,g;<br/> int Max(int,int);<br/> int Min(int,int);<br/> public:<br/> void Set(int,int,int,int,int,int,int,int);<br/> int Max();<br/> int Min();<br/> };<br/> int MaxMin8::Max(int v,int n)<br/> { if(v>n) return v;<br/> else return n;<br/> }<br/> int MaxMin8::Min(int v,int n)<br/> { if(v>n) return n;<br/> else return v;<br/> }<br/> void MaxMin8::Set(int x1=0,int x2=0,int x3=0,int x4=0,int x5=0,int x6=0, int x7=0,int x8=0)<br/> { a=x1;b=x2;c=x3;d=x4;e=x5;f=x6;j=x7;g=x8;<br/> cout<<"请输入八个数:"<<endl;<br/> cout<<"输入:"<<endl;<br/> cin>>a;<br/> cout<<"输入:"<<endl;<br/> cin>>b;<br/> cout<<"输入:"<<endl;<br/> cin>>c;<br/> cout<<"输入:"<<endl;<br/> cin>>d;<br/> cout<<"输入:"<<endl;<br/> cin>>e;<br/> cout<<"输入:"<<endl;<br/> cin>>f;<br/> cout<<"输入:"<<endl;<br/> cin>>j;<br/> cout<<"输入:"<<endl;<br/> cin>>g;<br/> }<br/> int MaxMin8::Max()<br/> { int x,y,h,s,z,v,n;<br/> x=Max(a,b);<br/> y=Max(c,d);h=Max(e,f);s=Max(j,g);<br/> z=Max(x,y);v=Max(h,s);n=Max(z,s);<br/> return n;<br/> }<br/> int MaxMin8::Min()<br/> { int x,y,z,h,s,v,n;<br/> x=Min(a,b);<br/> y=Min(c,d);h=Min(e,f);s=Min(j,g);<br/> z=Min(x,y);v=Min(h,s);n=Min(z,s);<br/> return n;<br/> }<br/> void main()<br/> {<br/> MaxMin8 M4;<br/> M4.Set();<br/> cout<<"输出最大值"<<M4.Max()<<endl;<br/> cout<<"输出最小值"<<M4.Min()<<endl;<br/> } |
|