4.17~4.22

4.17

#include<iostream>
using namespace std;
class Student
{
public:
	void setstu(int num,float s)
	{number=num;score=s;}
    void disp()
	{cout<<number<<" "<<score<<endl;}
private:
	int number;
	float score;
};
int main()
{
	Student stu[6];
	Student*p;
	stu[0].setstu(11,90);
    stu[1].setstu(12,90.5);
	stu[2].setstu(13,91);
	stu[3].setstu(14,92);
	stu[4].setstu(15,93);
	stu[5].setstu(16,89.5);
	p=stu;
	p=p+1;
	for(int i=1;i<=3;p=p+2,i++)
    p->disp();
	return 0;
}


4.18

#include <iostream>
using namespace std;
class Student
 {
public:
	Student(int, float);
	void max(Student* s);
private:
	int num;
	float score;
};
Student::Student(int n, float s):num(n),score(s){}
void Student::max(Student* s)
{
	int i, max_num=0, max_score=0;
	for(i=0;i<6;++i)
		if((s+i)->score > max_score)
		{max_score=(s+i)->score;
		max_num=(s+i)->num;}
		cout<<"所有学生中成绩最高学生的学号为:"<<max_num<< endl;}
int main()
{  int i;
	Student s[6]={Student(11,88),Student(12,91),Student(13,89),Student(14,92.5),Student(15,96),Student(16,92)};
	Student *p;
	p=&s[0];
	s[i].max(p);
	return 0;
}

4.19

#include<iostream>
using namespace std;
class book
{
public:
	book(int i)
	{
		qu=i;
		price=qu*10;
	}
	void disp()
	{
		cout<<"qu*price="<<qu*price<<endl;
	}
private:
	int qu;
	float price;
};
int main()
{
	int i;
	book b1[5]={1,2,3,4,5};
	for(i=0;i<5;i++)
	{
		b1[i].disp();
	}
	return 0;
}


4.20

#include<iostream>
using namespace std;
class book
{
public:
	void setbook(int i)
	{
		qu=i;
		price=qu*10;
	}
	void disp()
	{
		cout<<"qu*price="<<qu*price<<endl;
	}
private:
	int qu;
	float price;
};

int main()
{  
	book b1[5];
    book *p;
    b1[0].setbook(1);
    b1[1].setbook(2);
    b1[2].setbook(3);
    b1[3].setbook(4);
    b1[4].setbook(5);
	p=b1;
	int i;
    for(i=0;i<5;i++,p++)
		b1[4-i].disp();
	return 0;
}


4.21

#include<iostream>
#include<string>
using namespace std;
class Student
{
public:
	Student(string name1,int number1,float score1);
    void show();
	void show_count_sum_ave();
private:
	string name;
	int number;
	float score;
	static int count;
	static float sum;
	static float ave;
};
Student::Student(string name1,int number1,float score1)
{
	name=name1;
	number=number1;
	score=score1;
	count++;
	sum+=score;
	ave=sum/count;
}
void Student::show()
{
	cout<<"name:"<<name<<endl;
	cout<<"number:"<<number<<endl;
	cout<<"score:"<<score<<endl;}
void Student::show_count_sum_ave()
{
cout<<"count:"<<count<<endl;
cout<<"sum:"<<sum<<endl;
cout<<"ave:"<<ave<<endl;
}
int Student::count=0;
float Student::sum=0.0;
float Student::ave=0.0;
int main()
{Student stu1("Xiao",30,89);
stu1.show();
stu1.show_count_sum_ave();
Student stu2("Yuan",33,91);
stu2.show();
stu2.show_count_sum_ave();
Student stu3("Chen",2,82.5);
stu3.show();
stu3.show_count_sum_ave();
return 0;
}

4.22

#include <iostream>
#include <cmath>
using namespace std;
class Point
{
public:
    Point(float x1, float y1):x(x1),y(y1){}
	void showpoint()
	{
		cout << "(x,y)=(" <<x << "," << y << ")" << endl;
	}
    friend float dist(Point &, Point &);
private:
    float x;
    float y;
};
float dist(Point & A, Point & B)
{
   return sqrt((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y));
}
int main()
{
    Point a(1.2, 2);
    Point b(1.4, 3);
    a.showpoint();
    b.showpoint();
    cout << "a与b间的距离是:" << dist(a, b) <<endl;

    return 0;
}



freepdb.cmd文件解读 说明:@字符后面的是注释 if "%1"=="" ( @如果"%1"表示输入的参数如果为空,则进行如下处理 echo Usage: freepdb filename echo This will free all handles of VS2003 on filename.pdb echo Requires the Handle utility from Windows Sysinternals goto :eof ) cd /d "%~dp0" @进入freepdb.cmd文件所在的目录,因为需要使用的handle.exe和 @freepdb.cmd在同一个目录下 @以下部分说明:阅读时,请先查询dos命令 for的使用,第一个for循环来获取指定pdb文件的信息。 for /f "tokens=2,3 skip=5 delims=:" %%a in ('handle.exe -p devenv.exe "%1.pdb"') do ( for /f "tokens=1,4" %%c in ("%%a %%b") do ( handle -p %%c -c %%d -y >a.txt ) ) exit /b 0 @第一个for循环的含义是:运行in后面的括号里的命令语句,将结果按照/f 后面的命令来筛选出来, @@将到的结果分别放入了%%a, %%b中 @运行in后面括号中的语句后,得到的结果如下(调试我自己的程序打印出来的信息): @devenv.exe pid: 8960 type: File B70:E:\work\MainClient\new_src\Release\3DStock.pdb @然后取第2个字符串和第3个字符串,分别是(因为是通过“:”号来分割字符串的): @8960 type @File B70 @执行第2个循环语句 @第2个for循环,是从%%c(由%%a, %%b所合成的)中,取第一个字符串(默认通过空格来分割字符串)和第 @4个字符串 @运行in后面括号中的语句结果如下: @ 8960 type File B70 @然后取第1个字符串和第4个字符串,分别放入%%c, %%d中(8960是进程的id,B70是文件的句柄) @8960 @B70 @然后执行handle -p %%c -c %%d -y >a.txt命令 @即执行:handle -p 8960 -c B70 -y, 并将处理的结果存入a.txt ,存入文件是为了看到处理结果 @此命令是,杀掉指定进程ID的使用的文件句柄
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值