无题
来源:互联网 发布:c语言中mod是什么意思 编辑:程序博客网 时间:2024/05/29 15:30
// TestClass.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<stdlib.h>
#include <memory.h>
#include <windows.h>
#include <iostream>
using namespace std;
#define min(a , b) a>=b ? b:a
#define swap(a,b) {a=a+b;b=a-b;a=a-b;}
class Shape {
public:
// virtual int GetCircumference(){return 0;};
// virtual int GetArea(){return 0;};
virtual float GetCircumference(){return 0;};
virtual float GetArea(){return 0;};
};
class MyRound :public Shape
{
public:
MyRound(int r){m_r = r; };
float GetCircumference(){return m_r*3.14*2;};
float GetArea(){return m_r*3.14*m_r;};
private:
int m_r;
// MyRound(int r){m_r = r; };
};
class MyRect :public Shape
{
public:
MyRect(int Width, int Height){m_Width=Width; m_Height=Height;};
float GetCircumference(){return (m_Width+m_Height)*2;};
float GetArea(){return m_Width*m_Height;};
private:
int m_Width;
int m_Height;
};
typedef struct SHAPELIST
{
Shape *pAnyShape;
struct SHAPELIST *pNext;
};//SHAPELIST,*PSHAPELIST;
char myChar[8];
int main(int argc, char* argv[])
{
WORD *pW;
DWORD *pD;
char *pC;
memset(myChar,0,8);
pD= (unsigned long *)&myChar[0];
*pD++ = 0x3435;
*pD = 0x33;
pW= (unsigned short *)&myChar[3];
*pW = 0x3132;
pC = &myChar[2];
*pC = 0x33;
pC = &myChar[5];
*pC = 0x30;
printf("%s/n",myChar);
MyRect rc(2,3);
MyRound rd(1);
printf("MyRect::GetCircumference %f/n",rc.GetCircumference());
printf("MyRect::GetArea %f/n",rc.GetArea());
printf("MyRound::GetCircumference %f/n",rd.GetCircumference());
printf("MyRound::GetArea %f/n",rd.GetArea());
SHAPELIST * pHead;
pHead = new SHAPELIST;
pHead->pAnyShape = &rc ;
pHead->pNext = new SHAPELIST;
pHead->pNext->pAnyShape = &rd;
pHead->pNext->pNext = NULL;
printf("%f/n",pHead->pAnyShape->GetCircumference());
printf("%f/n",pHead->pAnyShape->GetArea());
printf("%f/n",pHead->pNext->pAnyShape->GetCircumference());
printf("%f/n",pHead->pNext->pAnyShape->GetArea());
printf("min(7,8):%d/n",min(7,8));
int a[3][4]={{11,12,13,14},{21,22,23,24},{31,32,33,34}};
int *p;
p= &a[0][0];
for(int i=0;i<12;i++)
{
printf("%d/n",*p);
p++;
}
/* int (*parray)[4] = a;
int j,k;
cin>>j>>k;
cout<<*(*(parray+j)+k)<<endl;
*/
int a1=2;
int b1 =3;
swap(a1,b1);
printf("swap(a1,b1): %d%d/n",a1,b1);
system("pause");
return 0;
}
- 无题
- 无题
- 无题
- 无题
- 无题
- 无题
- 无题
- 无题
- 无题
- 无题
- 无题
- 无题
- 无题
- 无题
- 无题。。。
- 无题
- 无题
- 无题
- win7休眠自动启动 作者:Lee 日期:2010-07-26
- Asp.Net 2.0的匿名用户的Profile
- ZOJ 1649 Rescue
- Spring AOP+ehCache简单缓存系统解决方案
- 袁崇焕
- 无题
- dojo.data学习
- 关于VB.NET的事件(event)(一)
- 【对于单链表复制错误的反思】
- org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'taglib'. 异常
- epoll的适应场景
- 游戏服务器架构设计中的一些思考
- RedHat LINUX Enterprise5 安装配置指南
- struts 2.0的Action讲解