日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內(nèi)最全IT社區(qū)平臺 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁 > 互聯(lián)網(wǎng) > 2014微軟實習(xí)生在線編程試題1

2014微軟實習(xí)生在線編程試題1

來源:程序員人生   發(fā)布時間:2014-08-30 16:40:39 閱讀次數(shù):4664次

2014微軟實習(xí)生在線編程試題1,大家一起來看看微軟有什么題目吧
1,Description

For this question, your program is required to process an input string containing only ASCII characters between ‘0’ and ‘9’, or between ‘a’ and ‘z’ (including ‘0’, ‘9’, ‘a’, ‘z’).

Your program should reorder and split all input string characters into multiple segments, and output all segments as one concatenated string. The following requirements should also be met,
1. Characters in each segment should be in strictly increasing order. For ordering, ‘9’ is larger than ‘0’, ‘a’ is larger than ‘9’, and ‘z’ is larger than ‘a’ (basically following ASCII character order).
2. Characters in the second segment must be the same as or a subset of the first segment; and every following segment must be the same as or a subset of its previous segment.

Your program should output string “<invalid input string>” when the input contains any invalid characters (i.e., outside the '0'-'9' and 'a'-'z' range).

Input

Input consists of multiple cases, one case per line. Each case is one string consisting of ASCII characters.

Output

For each case, print exactly one line with the reordered string based on the criteria above.

樣例輸入
aabbccdd
007799aabbccddeeff113355zz
1234.89898
abcdefabcdefabcdefaaaaaaaaaaaaaabbbbbbbddddddee
樣例輸出
abcdabcd
013579abcdefz013579abcdefz
<invalid input string>
abcdefabcdefabcdefabdeabdeabdabdabdabdabaaaaaaa
該問題主要采用哈希比較簡單,我就不做介紹了直接上代碼:下面代碼提交時TLE,實際上可以優(yōu)化例如設(shè)置temp1[255]存儲hash值是沒必要這么大。
  1. 01.#include<stdio.h>    
  2. 02.#include<stdlib.h>    
  3. 03.#include<string.h>    
  4. 04.char temp[10][100];   
  5. 05.   
  6. 06.void process(char *String)   
  7. 07.{   
  8. 08.    int temp1[256] = {0};   
  9. 09.   
  10. 10.    int index = 0;   
  11. 11.       
  12. 12.    if(String==NULL)   
  13. 13.        return ;   
  14. 14.       
  15. 15.    int len = strlen(String);   
  16. 16.    int i;   
  17. 17.    for(i = 0; i < len; i++)   
  18. 18.    {   
  19. 19.        if((String[i] >='0' && String[i] <='9') || (String[i] >= 'a' && String[i] <='z') )   
  20. 20.        {   
  21. 21.            index = String[i] - '0';   
  22. 22.            temp1[index]++;   
  23. 23.        }   
  24. 24.        else   
  25. 25.        {   
  26. 26.            printf("<invalid input string>");   
  27. 27.        }   
  28. 28.    }   
  29. 29.       
  30. 30.    index = 0;   
  31. 31.       
  32. 32.    while(1)   
  33. 33.    {   
  34. 34.        for(i = 0; i < 256; i++)   
  35. 35.        {   
  36. 36.               
  37. 37.            if(temp1[i] !=0)   
  38. 38.            {   
  39. 39.                String[index] = i + '0';   
  40. 40.                index++;   
  41. 41.                temp1[i]--;   
  42. 42.            }   
  43. 43.               
  44. 44.        }   
  45. 45.           
  46. 46.        if(index == len)   
  47. 47.        {   
  48. 48.            printf("%s\n", String);   
  49. 49.            return;   
  50. 50.        }   
  51. 51.    }   
  52. 52.}   
  53. 53.   
  54. 54.int main()   
  55. 55.{   
  56. 56.    int i = 0;   
  57. 57.    while(gets(temp[i++]) != NULL);   
  58. 58.    i--;   
  59. 59.    int j;   
  60. 60.    for(j = 0; j<i; j++)   
  61. 61.    {   
  62. 62.        process(temp[j]);   
  63. 63.    }   
  64. 64.    return 0;   
  65. 65.}   
  66. 66.       

 

生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學(xué)習(xí)有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關(guān)閉
程序員人生
主站蜘蛛池模板: 精品视频免费在线 | 精品久久精品 | 免费成人av在线 | 日本成人在线播放 | 亚洲狠狠干 | 日韩国产欧美综合 | 91久久精品国产91久久 | 免费国产在线视频 | av在线一| 欧美成人福利 | 久久91精品国产91久久跳 | 成人一区二 | 国产视频a | 精品国产精品 | 久久国精品| 久久精品国产一区二区三区不卡 | 国产a一三三四区电影 | 亚洲一级在线 | 国产成人精品免费视频大全 | 午夜日韩视频 | 毛片视频播放 | 精品久久久久久久久久 | 久久成人免费视频 | 成人午夜精品一区二区三区 | 色福利网 | 蜜乳av另类精品一区二区 | 欧美日韩在线看 | 精品国产一区二区三区在线观看 | 国产极品免费 | 日日操天天操夜夜操 | 精品人伦一区二区三区蜜桃网站 | 成人久久久精品乱码一区二区三区 | 国产一区二区三区在线 | 69国产精品成人96视频色 | 国产高清精品在线 | 精品一区二区三区在线播放 | 91精品国产综合久久久久久丝袜 | 亚洲欧美在线播放 | 欧美日韩视频 | 欧美国产在线视频 | 国产不卡视频在线 |