2012届华为校园招聘机试题
生活随笔
收集整理的這篇文章主要介紹了
2012届华为校园招聘机试题
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1、選秀節目打分,分為專家評委和大眾評委,score[] 數組里面存儲每個評委打的分數,judge_type[] 里存儲與 score[] 數組對應的評委類別,judge_type[i] == 1,表示專家評委,judge_type[i] == 2,表示大眾評委,n表示評委總數。打分規則如下:專家評委和大眾評委的分數先分別取一個平均分(平均分取整),然后,總分 = 專家評委平均分 ?* 0.6 + 大眾評委 * 0.4,總分取整。如果沒有大眾評委,則 總分 = 專家評委平均分,總分取整。函數最終返回選手得分。
? ? ? 函數接口 ? int cal_score(int score[], int judge_type[], int n)?
轉載請標明出處,原文地址:http://blog.csdn.net/hackbuteer1/article/details/11161557
int cal_score(int score[], int judge_type[], int n) {int i , TotalExpertScore , TotalPublictScore , ExpertNum , PublicNum;double res = 0;TotalExpertScore = TotalPublictScore = 0;ExpertNum = PublicNum = 0;for(i = 0 ; i < n ; ++i){if(1 == judge_type[i]) //專家評委{TotalExpertScore += score[i];++ExpertNum;}else //大眾評委{TotalPublictScore += score[i];++PublicNum;}}if(0 == PublicNum) //沒有大眾評委{return TotalExpertScore/ExpertNum;}else{res = 0.6*TotalExpertScore/ExpertNum + 0.4*TotalPublictScore/PublicNum;return (int)res;} }? ? ?2、給定一個數組input[] ,如果數組長度n為奇數,則將數組中最大的元素放到 output[] 數組最中間的位置,如果數組長度n為偶數,則將數組中最大的元素放到 output[] 數組中間兩個位置偏右的那個位置上,然后再按從大到小的順序,依次在第一個位置的兩邊,按照一左一右的順序,依次存放剩下的數。
? ? ? 例如:input[] = {3, 6, 1, 9, 7} ? output[] = {3, 7, 9, 6, 1}; ? ? ? ? ? ? input[] = {3, 6, 1, 9, 7, 8} ? ?output[] = {1, 6, 8, 9, 7, 3}
? ? ? 函數接口 ? void sort(int input[[, int n, int output[])
轉載請標明出處,原文地址:http://blog.csdn.net/hackbuteer1/article/details/11161557
void sort(int input[] , int n , int output[]) {int i , j , k , temp , mid;for(i = 0 ; i < n - 1 ; ++i) //冒泡排序(降序){for(j = 0 ; j < n - i - 1 ; ++j){if(input[j] < input[j+1]){temp = input[j];input[j] = input[j+1];input[j+1] = temp;}}}//formid = n>>1;j = mid - 1;k = mid + 1;output[mid] = input[0];for(i = 1 ; i < n ; ) //按照一左一右的順序{if(j >= 0)output[j--] = input[i++];if(k < n)output[k++] = input[i++];} }? ? ? 3、操作系統任務調度問題。操作系統任務分為系統任務和用戶任務兩種。其中,系統任務的優先級 < 50,用戶任務的優先級 >= 50且 <= 255。優先級大于255的為非法任務,應予以剔除?,F有一任務隊列task[],長度為n,task中的元素值表示任務的優先級,數值越小,優先級越高。函數scheduler實現如下功能,將task[] 中的任務按照系統任務、用戶任務依次存放到 system_task[] 數組和 user_task[] 數組中(數組中元素的值是任務在task[] 數組中的下標),并且優先級高的任務排在前面,優先級相同的任務按照入隊順序排列(即先入隊的任務排在前面),數組元素為-1表示結束。
? ? ? 例如:task[] = {0, 30, 155, 1, 80, 300, 170, 40, 99} ? ?system_task[] = {0, 3, 1, 7, -1} ? ?user_task[] = {4, 8, 2, 6, -1}
? ? ?? 函數接口 ? ?void scheduler(int task[], int n, int system_task[], int user_task[])
轉載請標明出處,原文地址:http://blog.csdn.net/hackbuteer1/article/details/11161557
void scheduler(int task[] , int n , int system_task[] , int user_task[]) {int i , j , k , index_user , index_system , temp;j = k = 0;index_user = index_system = 0;for(i = 0 ; i < n ; ++i){if(task[i] > 255){printf("This is illegal task!\n");}else if(task[i] >= 50 && task[i] <= 255) //用戶任務{user_task[index_user++] = i; //存儲用戶任務的下標}else //系統任務{system_task[index_system++] = i; //存儲系統任務的下標}}//for//對每個類型組中的任務進行優先級排序for(i = 0 ; i < index_user - 1 ; ++i) //冒泡排序{for(j = 0 ; j < index_user - i - 1 ; ++j){if( task[user_task[j]] > task[user_task[j+1]] ){temp = user_task[j];user_task[j] = user_task[j+1];user_task[j+1] = temp;}}}//forif(index_user < n)user_task[index_user] = -1;for(i = 0 ; i < index_system - 1 ; ++i) //冒泡排序{for(j = 0 ; j < index_system - i - 1 ; ++j){if( task[system_task[j]] > task[system_task[j+1]] ){temp = system_task[j];system_task[j] = system_task[j+1];system_task[j+1] = temp;}}}//forif(index_system < n)system_task[index_system] = -1; }
與50位技術專家面對面20年技術見證,附贈技術全景圖
? ? ? 函數接口 ? int cal_score(int score[], int judge_type[], int n)?
轉載請標明出處,原文地址:http://blog.csdn.net/hackbuteer1/article/details/11161557
int cal_score(int score[], int judge_type[], int n) {int i , TotalExpertScore , TotalPublictScore , ExpertNum , PublicNum;double res = 0;TotalExpertScore = TotalPublictScore = 0;ExpertNum = PublicNum = 0;for(i = 0 ; i < n ; ++i){if(1 == judge_type[i]) //專家評委{TotalExpertScore += score[i];++ExpertNum;}else //大眾評委{TotalPublictScore += score[i];++PublicNum;}}if(0 == PublicNum) //沒有大眾評委{return TotalExpertScore/ExpertNum;}else{res = 0.6*TotalExpertScore/ExpertNum + 0.4*TotalPublictScore/PublicNum;return (int)res;} }? ? ?2、給定一個數組input[] ,如果數組長度n為奇數,則將數組中最大的元素放到 output[] 數組最中間的位置,如果數組長度n為偶數,則將數組中最大的元素放到 output[] 數組中間兩個位置偏右的那個位置上,然后再按從大到小的順序,依次在第一個位置的兩邊,按照一左一右的順序,依次存放剩下的數。
? ? ? 例如:input[] = {3, 6, 1, 9, 7} ? output[] = {3, 7, 9, 6, 1}; ? ? ? ? ? ? input[] = {3, 6, 1, 9, 7, 8} ? ?output[] = {1, 6, 8, 9, 7, 3}
? ? ? 函數接口 ? void sort(int input[[, int n, int output[])
轉載請標明出處,原文地址:http://blog.csdn.net/hackbuteer1/article/details/11161557
void sort(int input[] , int n , int output[]) {int i , j , k , temp , mid;for(i = 0 ; i < n - 1 ; ++i) //冒泡排序(降序){for(j = 0 ; j < n - i - 1 ; ++j){if(input[j] < input[j+1]){temp = input[j];input[j] = input[j+1];input[j+1] = temp;}}}//formid = n>>1;j = mid - 1;k = mid + 1;output[mid] = input[0];for(i = 1 ; i < n ; ) //按照一左一右的順序{if(j >= 0)output[j--] = input[i++];if(k < n)output[k++] = input[i++];} }? ? ? 3、操作系統任務調度問題。操作系統任務分為系統任務和用戶任務兩種。其中,系統任務的優先級 < 50,用戶任務的優先級 >= 50且 <= 255。優先級大于255的為非法任務,應予以剔除?,F有一任務隊列task[],長度為n,task中的元素值表示任務的優先級,數值越小,優先級越高。函數scheduler實現如下功能,將task[] 中的任務按照系統任務、用戶任務依次存放到 system_task[] 數組和 user_task[] 數組中(數組中元素的值是任務在task[] 數組中的下標),并且優先級高的任務排在前面,優先級相同的任務按照入隊順序排列(即先入隊的任務排在前面),數組元素為-1表示結束。
? ? ? 例如:task[] = {0, 30, 155, 1, 80, 300, 170, 40, 99} ? ?system_task[] = {0, 3, 1, 7, -1} ? ?user_task[] = {4, 8, 2, 6, -1}
? ? ?? 函數接口 ? ?void scheduler(int task[], int n, int system_task[], int user_task[])
轉載請標明出處,原文地址:http://blog.csdn.net/hackbuteer1/article/details/11161557
void scheduler(int task[] , int n , int system_task[] , int user_task[]) {int i , j , k , index_user , index_system , temp;j = k = 0;index_user = index_system = 0;for(i = 0 ; i < n ; ++i){if(task[i] > 255){printf("This is illegal task!\n");}else if(task[i] >= 50 && task[i] <= 255) //用戶任務{user_task[index_user++] = i; //存儲用戶任務的下標}else //系統任務{system_task[index_system++] = i; //存儲系統任務的下標}}//for//對每個類型組中的任務進行優先級排序for(i = 0 ; i < index_user - 1 ; ++i) //冒泡排序{for(j = 0 ; j < index_user - i - 1 ; ++j){if( task[user_task[j]] > task[user_task[j+1]] ){temp = user_task[j];user_task[j] = user_task[j+1];user_task[j+1] = temp;}}}//forif(index_user < n)user_task[index_user] = -1;for(i = 0 ; i < index_system - 1 ; ++i) //冒泡排序{for(j = 0 ; j < index_system - i - 1 ; ++j){if( task[system_task[j]] > task[system_task[j+1]] ){temp = system_task[j];system_task[j] = system_task[j+1];system_task[j+1] = temp;}}}//forif(index_system < n)system_task[index_system] = -1; }
與50位技術專家面對面20年技術見證,附贈技術全景圖
總結
以上是生活随笔為你收集整理的2012届华为校园招聘机试题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2013届华为校园招聘机试题
- 下一篇: 2013豆瓣校园招聘研发类笔试题