1
#include <iostream>
using namespace std;
int mul(int a,int b,int c=10);
int main()
{
cout << "input a b ";
int a,b;
cin >> a >> b;
//cin >> b;
cout << mul(a,b) << endl;
return 0;
}
int mul(int a,int b,int c)
{
return a*b*c;
}
2
#include <iostream>
using namespace std;
class stu{
private:
int age;
char sex;
int high;
public:
double score;
int get_age();
void set_age(int a);
char get_sex();
void set_sex(char b);
int get_high();
void set_high(int c);
};
int stu::get_age()
{
return age;
}
void stu::set_age(int a)
{
age=a;
}
char stu::get_sex()
{
return sex;
}
void stu::set_sex(char b)
{
sex=b;
}
int stu::get_high()
{
return high;
}
void stu::set_high(int c)
{
high=c;
}
int main()
{
class stu a;
int x;
char y;
int z;
int m;
cout << "input age:";
cin >> x;
a.set_age(x);
cout << "input sex:";
cin >> y;
a.set_sex(y);
cout << "input high:";
cin >> z;
a.set_high(z);
cout << "input score:";
cin >> m;
a.score=m;
cout << "age=" << a.get_age() << endl;
cout << "sxe=" << a.get_sex() << endl;
cout << "high=" << a.get_high() << endl;
cout << "score=" << a.score << endl;
return 0;
}
3