1 #include<iostream> 2 using namespace std; 3 int main() 4 { 5 int N,a,b,c,i,n,sum=0; 6 cin>>N;cout<<endl; 7 8 for(i=0;i<N;i++) 9 { 10 cin>>a>>b;cout<<endl; 11 12 sum+=b; 13 } 14 15 c=sum/N; 16 cout<<c<<endl; 17 18 19 }
1 #include<iostream> 2 using namespace std; 3 class Mammal 4 { 5 private: 6 int itsAge; 7 int itsWeight; 8 public: 9 Mammal(int a,int b) 10 { 11 itsAge=a; 12 itsWeight=b; 13 } 14 void setweight(int weight) 15 { 16 itsWeight=weight; 17 } 18 void getweight() 19 { 20 cout<<itsWeight<<endl; 21 } 22 void getage() 23 { 24 cout<<itsAge<<endl; 25 } 26 }; 27 class Dog:public Mammal 28 { 29 private: 30 int pinzhong; 31 public: 32 Dog(int a,int b,int c):Mammal(a,b) 33 { 34 pinzhong=c; 35 } 36 void getpinzhong() 37 { 38 cout<<pinzhong<<endl; 39 } 40 void yuyan() 41 { 42 cout<<"wangwangwang"<<endl; 43 Mammal::getweight(); 44 Mammal::getage(); 45 } 46 }; 47 int main() 48 { 49 Dog d(1,10,2); 50 cout<<"年龄:"; 51 d.getage(); 52 cout<<"体重:"; 53 d.getweight(); 54 cout<<"品种:"; 55 d.getpinzhong(); 56 d.yuyan(); 57 }
1 #include<iostream> 2 using namespace std; 3 class Base0{ 4 public: 5 int var0; 6 void fun0(){cout<<"Member of Base0"<<endl; 7 } 8 }; 9 class Base1:public Base0{ 10 public: 11 int var1; 12 }; 13 class Base2:public Base0{ 14 public:int var2; 15 }; 16 class Derived:public Base1,public Base2{ 17 public: 18 int var; 19 void fun(){ 20 cout<<"Member of Derived"<<endl;} 21 }; 22 int main() 23 { 24 Derived d; 25 d.Base1::var0=2; 26 d.Base1::fun0(); 27 d.Base2::var0=3; 28 d.Base2::fun0(); 29 return 0; 30 } 31 32 33 #include<iostream> 34 using namespace std; 35 class Base1{ 36 public: 37 int var; 38 void fun(){cout<<"Member of Base1"<<endl;} 39 }; 40 class Base2{ 41 public: 42 int var; 43 void fun(){cout<<"Member of Base2"<<endl;} 44 }; 45 class Derived:public Base1,public Base2{ 46 public: 47 int var; 48 void fun(){cout<<"Member of Derived"<<endl;} 49 }; 50 int main() 51 { 52 Derived d; 53 Derived*p=&d; 54 d.var=1;
标签:std,cout,int,void,namespace,4.20,using From: https://www.cnblogs.com/lijianlongCode13/p/17338426.html