華為模擬機試題

2021-06-29 10:21:02 字數 1551 閱讀 2965

1.密碼擷取:

如12332145擷取123321回文數

輸入:數字

輸出:回文數的位數

/*#include//自己寫的,測試用例有1錯

using namespace std;

int main()

else

}if(count>max)

max=count;

count=0;

}cout}}*/

# include//網上

using namespace std;

# include

int main(void)

for(j=0;i-j>=0 && i+j+1max) max = 2*j+2;}}

printf("%d\n",max);

memset(a,0,sizeof(a));

}return 0;

}2.遞減數,如75345323,遞減數有753,53,53,532,32

最大的遞減數為753

各位數和最大的是7+5+3=15,最大的為753

輸入:整數,負數轉為整數操作

輸出:最大遞減數和各位和最大遞減數之和

/*#include

using namespace std;

#include

int main()

for(i=0;i

//b[i]=a%(pow(10,i+1))/pow(10,i);

//int start1=0;

//int start2=1;

for(i=0;i

//break;

//b[i]//cout<

}for(i=0;i

//for(i=0;i)

//cout<<(a);

return 0;

}*/#include

using namespace std;

int getmax(int num)

else

temp = s[i] - '0';

if (temp > max && flag>0)

max = temp;

}return max;

}int getaddmax(int num)

//else//}

else

if (temp1 > maxsum && flag>0)

}return max;

}int main()

cout<}

return 0;

}int sprintf( char *buffer, const char *format, [ argument] … );

主要功能是把格式化的資料寫入某個字串中。

#include/*某個stdio.h*/

intmain()/*主函式「整數」型別*/

輸出結果:

[5 plus 3 is 8] is a string 13 chars long

華為機試題

今天去華為機試,感覺是再謹慎都不為過啊!zc前一天晚上還跟我強調了判空,記憶體釋放。前兩題都是基本題,後面一題不會。1 輸入兩個數 反轉相加的和輸出。2 三天打漁兩天曬網 從1990 年1月1日開始 打漁輸出fishing 曬網輸出sleeping 我因為printf的是fishing sleepi...

華為機試題

通過鍵盤輸入一串小寫字母 a z 組成的字串。請編寫乙個字串壓縮程式,將字串中連續出席的重複字母進行壓縮,並輸出壓縮後的字串。壓縮規則 1.僅壓縮連續重複出現的字元。比如字串 abcbc 由於無連續重複字元,壓縮後的字串還是 abcbc 2.壓縮欄位的格式為 字元重複的次數 字元 例如 字串 yyy...

華為機試題

1.輸入乙個字串,將字串中的非字母字元刪除,保留字串中的小寫字母,將大寫字母變為小寫字母,然後輸出字串。比如 輸入 sdf sfjadf sdf 輸出 sdfsfjadfsdf 2.n進製數求和,輸入乙個整數n 2 n 35 兩個字串,字串中的字元一定是0 9或者a z 10 35 中的,輸出兩個字...