c++编程13两题!

 

1:

#include <iostream>
#include <string>
using namespace std;
class Student
{
public:
	char* name;  
	int age;
	int xuehao;
	Student(){name = 0;}
	~Student(){if(name) delete[] name; name =0;}
};

int main()
{
	Student st;
	st.xuehao = 1001;
	st.name = new char[strlen("张三")+1];
	memcpy(st.name,"张三",strlen("张三"));
	st.name[strlen("张三")] = 0;
	st.age = 22;

	cout << st.xuehao << "  " << st.name << " " << st.age << endl;
	return 0;
}

3:

#include <iostream>
using namespace std;

int main()
{
	int i=1;
	int s = 1;
	for (i=1;i<=15;i++)
	{
		s *= i;
	}
	cout << "15!=" << s << endl;
	return 0;
}