flag=stringCompare(str1,str2); cout<<\}
int stringCompare(char s1[10],char s2[10]) { int n; for(int i=0;i<10;i++){ n=s1[i]-s2[i]; if(n==0)return 0; else if(n>0)return 1; else return -1; } }
4. 下列代码是CmyPoint类的定义,请写出类的构造函数。 class CmyPoint {
private:
int X,Y; public:
CmyPoint(int x,int y); CmyPoint(CmyPoint& p); CmyPoint(){} ~CmyPoint(){}
int getX() { return X; } int getY() { return Y; } };
CmyPoint::CmyPoint(int x,int y){ X=x; Y=y; }
CmyPoint::CmyPoint(CmyPoint& p){ X=p.X; Y=p.Y; }
6
C-C++习题一期末考试例题(附答案) - 图文
flag=stringCompare(str1,str2);cout<<\}intstringCompare(chars1[10],chars2[10]){intn;for(inti=0;i0)return1;el
推荐度:
点击下载文档文档为doc格式