Cheetah mobile (Jinshan Network) 2015 campus recruitment (c ++ engineers), 2015 campus recruitment

Source: Internet
Author: User

Cheetah mobile (Jinshan Network) 2015 campus recruitment (c ++ engineers), 2015 campus recruitment


1. the prototype of the known class MyString is:

Class MyString
{
Public: MyString (const char * str = NULL); // common Constructor
MyString (const MyString); // copy the constructor
~ MyString (void); // destructor
MyString & operator = (const MyString); // value assignment Constructor
Private: char * m_c_data; // used to save strings

}; Write the above four functions of MyString.

Programmer interview guide p112

Class MyString {public: MyString (const char * str = NULL); // normal constructor MyString (const MyString & other); // copy constructor ~ MyString (void); // destructor MyString & operator = (const MyString & other); // value assignment constructor private: char * m_data; // used to save the string }; myString: MyString (const char * str) // constructor {if (str = NULL) {m_data = new char [1]; * m_data = '\ 0 ';} else {int length = strlen (str); m_data = new char [length + 1]; strcpy (m_data, str) ;}} MyString ::~ MyString (void) // destructor {delete [] m_data; // Since m_data is an internal data type, you can also write delete m_data;} MyString :: myString (const MyString & other) // copy the constructor {int length = strlen (other. m_data); m_data = new char [length + 1]; strcpy (m_data, other. m_data);} MyString & MyString: operator = (const MyString & other) // value assignment function {if (this = & other) // check the self-assigned return * this; delete [] m_data; // release the original memory resource int length = strlen (other. m_data); // allocate new memory resources and copy the content m_data = new char [length + 1]; strcpy (m_data, other. m_data); return * this; // return the reference of this object}

2. merge the two data sequences into a data with no identical elements in sequence.

For example, s1 [5] = {, 24}, s2 [5] = {, 19, 25}
Output 10, 14, 24, 25, 62 after execution

Note: library functions cannot be used.

#include<iostream>using namespace std;int main(){int s1[5]={23,14,62,57,24},s2[5]={14,19,10,14,25};int s3[10],i,j,k,t;int flag;s3[0]=s1[0];k=1;for(i=1;i<5;i++){flag=1;for(j=0;j<k;j++){if(s1[i]==s3[j]){flag=0;break;}}if(flag==1)s3[k++]=s1[i];}for(i=0;i<5;i++){flag=1;for(j=0;j<k;j++){if(s2[i]==s3[j]){flag=0;break;}}if(flag==1)s3[k++]=s2[i];}for(i=0;i<k-1;i++){for(j=0;j<k-1-i;j++){if(s3[j]>s3[j+1]){t=s3[j];s3[j]=s3[j+1];s3[j+1]=t;}}}for(i=0;i<k;i++){cout<<s3[i]<<" ";}return 0;}


3. print A matrix of N * N. N is the number of characters on each side (3 <N <20). The outermost layer must be "A" and the second layer must be "B ", print numbers 0, 1, 2, 3 ,...... Example: when n = 5, print the following figure
AAAAA
ABBBA
AB0BA
ABBBA

AAAAA

#include<cstring>#include<iostream>using namespace std;int main(){int N;int i,j,k,m;char a[20][20];cin>>N;for(i=0;i<(N+1)/2;i++){ if(i==0) {for(j=0;j<N;j++)a[j][i]=a[i][j]=a[j][N-i-1]=a[N-i-1][j]='A';}else if(i==1){for(j=1;j<N-i;j++)a[j][i]=a[i][j]=a[N-i-1][j]=a[j][N-i-1]='B';}else {for(j=i;j<N-i;j++)a[j][i]=a[i][j]=a[N-i-1][j]=a[j][N-i-1]=i-2+'0';}}for(i=0;i<N;i++){for(j=0;j<N;j++){cout<<a[i][j]<<" ";}cout<<endl;}return 0;}


No program is written on paper ~ Sometimes it's really a crash and you can't find the sadness of your job ~ Who can understand


Some websites can be opened by others, and I cannot open them. On the page, the cheetah browser + Kingsoft + mobile broadband solution is displayed.

Hello, this is why IE cannot display this webpage. We recommend that you switch to quick mode to try it and see if it can be opened normally? If the rapid mode still does not work, it is not a browser problem, it may be related to your local network restrictions, it is recommended that you pay attention to security when accessing such websites.

If you still have any questions, please contact Kingsoft Enterprise
Liu Honglong [authoritative expert]

Jinshan Network (cheetah mobile) has staff canteen or Chinese food and dinner subsidies?

Hello, this is acceptable. I personally estimate that his facilities should be well-developed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.