资源描述:
《自己整理的c面试常考程序题》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、1./*字符串倒置*/#include#includevoidfunc(char*str){intbeg,end;chartem;for(beg=0,end=strlen(str)-1;beg
2、#includestructNode{intdata;structNode*next;};intmain(){intm,n,i;printf("inputnumber:");scanf("%d",&m);structNode*head,*r,*p,*q;head=(structNode*)malloc(sizeof(structNode));p=head;for(i=1;i<=m;i++){r=(structNode*)malloc(sizeof(structNode));r->data=i;p->next=r;p=r;}p->next
3、=head->next;p=p->next;printf("startis:");scanf("%d",&n);intj=1;while(jnext;j++;}ints;printf("间隔为:");scanf("%d",&s);do{for(i=1;i<=s-1;i++)20currencydeposit,weprescribeapassonaregularbasis,qilucardaccountonaregularbasis),certificatebondsandsavingsbonds(electronic);3.notdraw
4、nonabanksavingscertificate,certificatebondsapplyformortgageloans,acceptingonlythelenderp=p->next;q=p->next;printf("%d",q->data);p->next=q->next;free(q);p=p->next;m--;}while(m>0);return0;}3./*String类的实现*/#include#includeusingnamespacestd;classString{public:Strin
5、g(constchar*data=NULL){if(data==NULL){m_data=newchar[1];*m_data=' ';}else{m_data=newchar[strlen(data)+1];strcpy(m_data,data);}}String(constString&other){m_data=newchar[strlen(other.m_data)+1];strcpy(m_data,other.m_data);}~String(void){delete[]m_data;}String&operator=(constString&
6、other){if(this==&other)return*this;delete[]m_data;m_data=newchar[strlen(other.m_data)+1];strcpy(m_data,other.m_data);}voidprint(void){puts(m_data);}private:char*m_data;};intmain(){Strings("liushaohui");s.print();Stringp(s);p.print();20currencydeposit,weprescribeapassonaregularbasi
7、s,qilucardaccountonaregularbasis),certificatebondsandsavingsbonds(electronic);3.notdrawnonabanksavingscertificate,certificatebondsapplyformortgageloans,acceptingonlythelenderString*t=newString("haojiahuo");t->print();Stringq;q=s;q.print();return0;}4./*定义一个Person类,实现堆的功能*/#include<
8、iostream>usingnamespacestd;classP