View Mode: Normal | Article List
Category: Man's C++ | 1
#include <iostream> //使用头文件
using namespace std; //命名空间
void main() //主函数,返回值为INT型
{
int *pt=new int;
double *pn=new double;
*pt=10000;
*pn=10000000.10;
cout<<"int *pt="<<*pt<<",The location is:"<<pt<<endl;
cout<<"double *pn="<<*pn<<",The location is:"<<pn<<endl;
cout<<"size of *pt="<<sizeof(*pt)<<",size of pt="<<sizeof(pt)<<endl;
cout<<"size of *pn="<<sizeof(*pn)<<",size of pn="<<sizeof(pn)<<endl;
cin.get();
}
using namespace std; //命名空间
void main() //主函数,返回值为INT型
{
int *pt=new int;
double *pn=new double;
*pt=10000;
*pn=10000000.10;
cout<<"int *pt="<<*pt<<",The location is:"<<pt<<endl;
cout<<"double *pn="<<*pn<<",The location is:"<<pn<<endl;
cout<<"size of *pt="<<sizeof(*pt)<<",size of pt="<<sizeof(pt)<<endl;
cout<<"size of *pn="<<sizeof(*pn)<<",size of pn="<<sizeof(pn)<<endl;
cin.get();
}
字符串数组的操作练习
[ 2009-03-24 11:53:02 | Author: adobo ]
#include <iostream>
#include <cstring>
int main()
{
using namespace std;
const int iSize=15;//
char cYourName[iSize];
char cMyName[iSize]="AiYunchao";
cout<<"Hello,My Name is "<<cMyNam e<<endl;
cout<<"What\'s is your name?"<<endl;
cin>>cYourName;
cout<<"Yeah,"<<cYourName<<",Your name has "<<strlen(cYourName)<<" chars"<<endl;//测试输入名称的长度,strlen库函数来自#include <cstring>
cout<<"It spands ...
Read More...
#include <cstring>
int main()
{
using namespace std;
const int iSize=15;//
char cYourName[iSize];
char cMyName[iSize]="AiYunchao";
cout<<"Hello,My Name is "<<cMyNam e<<endl;
cout<<"What\'s is your name?"<<endl;
cin>>cYourName;
cout<<"Yeah,"<<cYourName<<",Your name has "<<strlen(cYourName)<<" chars"<<endl;//测试输入名称的长度,strlen库函数来自#include <cstring>
cout<<"It spands ...
Read More...
开始学习C++,第一个完整程序
[ 2009-03-24 00:24:12 | Author: adobo ]
//这是一个将秒转换成几天几时几分几秒的程序
#include <iostream> //使用头文件
using namespace std; //命名空间
const int HOUR_TO_DAY=24; //CONST限定符,定义常量
const int MIN_TO_HOUR=60;
const int SEC_TO_MIN=60;
int main() //主函数,返回值为INT型
{
long lSec; //定义长整型
cout<<"Enter The Seconds:______\b\b\b\b\b\b"; //采用下划线
cin>>lSec;//输入
int iDay,iHour,iMin,iSec;//定义天,时,分,秒
iSec=lSec%SEC_TO_MIN;//计算秒
iMin=((lSec-iSec)/SEC_TO_MIN)%MIN_TO_HOUR;//计算分
...
Read More...
#include <iostream> //使用头文件
using namespace std; //命名空间
const int HOUR_TO_DAY=24; //CONST限定符,定义常量
const int MIN_TO_HOUR=60;
const int SEC_TO_MIN=60;
int main() //主函数,返回值为INT型
{
long lSec; //定义长整型
cout<<"Enter The Seconds:______\b\b\b\b\b\b"; //采用下划线
cin>>lSec;//输入
int iDay,iHour,iMin,iSec;//定义天,时,分,秒
iSec=lSec%SEC_TO_MIN;//计算秒
iMin=((lSec-iSec)/SEC_TO_MIN)%MIN_TO_HOUR;//计算分
...
Read More...
1







