-
int main() { double x,y,means; cout << " enter 2 number \n"; cin >> x >> y; //cin.get(); while(x!=0 and y!=0) // while(!x and !y) { means = mean(x,y); cout << means << endl; cin >> x >> y ; //cin.get(); } } double mean(double x,double y) { return 2.0*x*y/(x+y); }
-
int main() { float a[N],d; int f; cout << "enter 10 number \n"; f=input(a,N,0);//赋全0初值; f=input(a,N,1); show(a,N); d=mean(a,f); cout << d << endl; } float mean(float *a,int n ) { float sum = 0.0; int m= n; for(n--;n>=0;n--) { sum+=a[n]; cout << a[n] <<"sum : "<< sum <<endl; } return sum/m; } void show(float *a,int n ) { for(;n>0;n--) { cout << a[N-n] << endl; } } int input(float *a,int n,int flag ) { for(;n>0;n--) { if (flag == 0) {a[N-n]=0;} else { cin >> a[N-n]; if (cin.get() == '\n') break; } } return N-n; }
-
void m_7_3() { box boxx={"who",1.2,2.3,3.4,4.5}; show(boxx); b(&boxx); } void show(box m) { cout << m.maker <<endl; cout << m.height << endl; cout << m.width << endl; cout << m.length << endl; cout << m.volume << endl; } void b(box *m) { m->volume = m->height * m->width * m->length; cout << m->volume; }
-
void m_7_4() { double p; for(int i = 5;i >0 ;i--) { p*=(6.0-i)/(48-i); } cout << p/27.0; }
-
c++第7章课后编程
最新推荐文章于 2023-06-02 20:07:21 发布