14.
void updatedata(char *p)
{int i,j;
i=j=0;
for(;p!='\0';p++){
if(*p='D')i++;
else if(*p='d')j++;
else continue;
}
printf("D count=%d,d count=%d\n",i,j)
}
15.
char *string(char *a,char *s)
{char *p,*q,*r;
p=r=a;
q=s;
while(p!='\0'||q!='\n'){
if(*p==*q){p++;q++;}
else {p++;r=p;q=s;}
}
return(r);
}
16.
void count(char *s)
{int i,j;
i=j=0;
while(s!='\0'){
if(*s>=48&&*s<=57)i++;
else if(*s>=65&&*s<=90||*s>=97&&*s<=122)j++;
else continue;
}
printf("num count=%d,character count=%d\n",i,j);
}
17.
class rectangle
{public:
rectangle(int i,int j){x=i;y=j;}
int MJ(){return x*y;}
int ZC(){return 2*(x+y);}
void print(){cout<<"MJ="<
int x,y;
}
void main()
{rectangle a(23,45);
a.print();
}
18.
有了17的思路自己想想18吧 用一个函数:功能是用p2.x-p1.x求长 用p2.y-p1.y求宽 之后就可以求面积和周长了。
19.
和17一样的 在面积乘以1/2 周长=x+y+sqrt(x*x+y*y);
20.21 自己思考;
22.
class student
{public:
student(int n,char nam[],float a[]){
num=n;
strcpy(name,nam);
grade[0]=a[0];
grade[1]=a[1];
grade[2]=a[2];
}
void avg(){cout<<"avg="<<(grade[0]+grade[1]+grade[2])/3<
int num;
char name[10];
float grade[3];
}
void main()
{student a(20061001,"刘云君","89,67,88");
a.show();
a.avg();
}
上面的都没调试过,我也是位C++新鸟,程序不一定保证对,我只是想为你提供些思路,下面的题目就不帮你做了,想学程序还是要靠自己多动手,看书和问别人都不及自己试着去写代码,希望你能有所进步!
yun
zhe me duo
太多了,还是自己搞定比较好,都很简单啊