posts - 30,  comments - 28,  trackbacks - 0
          華為筆試題:計算字符串“010111001100....”中‘0’和‘1’連續出現的次數。

          #include<iostream>;

          void main() {

          ???char *charArray="01000111100011100111100001";
          ???int max[2]?? ?={0,0};
          ???int count[2]? ={0,0};

          ? while(*charArray){
          ??????
          ? int?? index???? =*charArray-'0';

          ? count[index]++;
          ??count[index^1] =0;

          ? if(count[index]>max[index])
          ?????? ?max[index]=count[index];

          ? charArray++;
          ? }
          ?
          ?std:cout<<"Max times of 0 is"<<max[0]<<std:endl;
          ?std:cout<<"Max times of 1 is"<<max[1]<<std:endl;
          }
          //~:end the codes

          程序代碼的藝術化,呵呵
          posted on 2006-09-26 03:57 murainwood 閱讀(368) 評論(0)  編輯  收藏 所屬分類: C++&C

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          <2006年9月>
          272829303112
          3456789
          10111213141516
          17181920212223
          24252627282930
          1234567

          如果真的給你一片天,你敢不敢要?

          常用鏈接

          留言簿(3)

          隨筆分類

          隨筆檔案

          相冊

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 明星| 丁青县| 牙克石市| 肇州县| 平顶山市| 福鼎市| 大邑县| 买车| 平武县| 五家渠市| 武穴市| 比如县| 招远市| 阳信县| 绥阳县| 浦县| 邓州市| 南安市| 吉林市| 拜泉县| 教育| 合江县| 鄂托克旗| 新营市| 自治县| 红河县| 伊金霍洛旗| 古田县| 米泉市| 余江县| 错那县| 塘沽区| 天门市| 韩城市| 辽中县| 洞头县| 乐清市| 南通市| 建阳市| 上杭县| 台州市|