life02
C++博客
::
首頁
::
新隨筆
::
聯系
::
聚合
::
管理
::
197 隨筆 :: 3 文章 :: 37 評論 :: 0 Trackbacks
<
2009年9月
>
日
一
二
三
四
五
六
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
4
5
6
7
8
9
10
常用鏈接
我的隨筆
我的評論
我參與的隨筆
留言簿
(4)
給我留言
查看公開留言
查看私人留言
隨筆分類
(179)
android ndk開發(6)
(rss)
Android開發(71)
(rss)
android面試題(4)
(rss)
android模擬器學習(7)
(rss)
android組件學習(15)
(rss)
c++學習(9)
(rss)
laucher開發(轉載)(7)
(rss)
OGRE(1)
(rss)
筆試(24)
(rss)
簡歷(6)
(rss)
算法(7)
(rss)
游戲開發(3)
(rss)
源碼學習(19)
(rss)
隨筆檔案
(197)
2012年7月 (1)
2012年4月 (13)
2012年3月 (40)
2012年2月 (20)
2012年1月 (10)
2011年12月 (47)
2011年11月 (4)
2011年10月 (1)
2011年8月 (3)
2011年7月 (1)
2011年6月 (4)
2011年3月 (1)
2011年2月 (1)
2010年12月 (4)
2010年4月 (2)
2010年2月 (1)
2009年11月 (3)
2009年10月 (16)
2009年9月 (22)
2009年8月 (3)
文章分類
(1)
轉載--OGRE(1)
(rss)
文章檔案
(3)
2010年12月 (1)
2009年9月 (1)
2009年8月 (1)
收藏夾
(16)
c++游戲開發(2)
(rss)
筆\面試經驗(5)
(rss)
筆試題(9)
(rss)
Android開發
Android 源碼
(rss)
feng88724(android)
get android source
Himi-android game
java-admin
Sunboy_2050的專欄
widebright的個人空間
八度空間 一點點技術,一點點文藝
點點
愷風(Wei)的專欄
思想實踐地
移動平臺碎碎念
c++blog——游戲
3d Game Walkman
AI_blog
AI-CODE.ORG
AI博客集合
A東亮——blog
賴勇浩的編程私伙局
牛蛙社團隊
牽著老婆滿街逛
清源游民的網絡筆記本
王者風范 浩蕩天下
業內網面試筆試綜合版
游戲程序員養成計劃
重劍無鋒,大巧不工
c++學習
A老牛
c++虛函數
編程之美
QQblog
我想我是鳥
阿里巴巴
楊爭的專欄
筆試
技術網站
AIGameDev
android 學習視頻
(rss)
http://www.mars-droid.com/
Android開發指南中文版
C/C++ Reference
CSDN
Game Programming Wiki
GameDev.NET
linux學習
sourceforge.net
STL學習
STL中文站
軟件測試
數據結構
游戲學習
游戲學習網站
搜索
最新評論
1.?re: Android開發多線程斷點續傳下載器 (轉載)
這個handler是不是只能放在外面?
還有哪些地方 。
--25Age
2.?re: An internal error occurred during: "Launching New_configuration"
這個問題,這樣解決不了?。。。∵€有其他辦法木啊
--李大明
3.?re: Ubuntu 中學習 C/C++ 編程基礎入門教程
fugkgfyuk
--46546416
4.?re: IconUtilities類的createIconBitmap方法分析
分析在哪里?
--bs
5.?re: android SD卡文件的讀寫(z轉載)
不錯,有幫助
--brief
閱讀排行榜
1.?類string的構造函數、拷貝構造函數和析構函數(6497)
2.?Android中Context詳解 ---- 你所不知道的Context (轉載)(6323)
3.?RJ48線序及RJ48的自環線纜做法(6157)
4.?android控件詳解----TextView(轉載)(5450)
5.?canvas 里drawbitmap方法(5244)
評論排行榜
1.?如何判斷一點在三角形內(轉)(8)
2.?類string的構造函數、拷貝構造函數和析構函數(4)
3.?深信服筆試(轉)(4)
4.?Android開發多線程斷點續傳下載器 (轉載)(2)
5.?筆試題(2)
字符串循環移位 - 編程珠璣的一道題(轉)
//
編程珠璣 第二章 字符串string循環移位i位
//
eg "abcdefgh" 循環移位 3位 =》 "defghabc"
#include
<
iostream.h
>
#include
<
string
.h
>
char
*
string_cyclicshift_v2(
char
*
string
,
int
i )
{
char
ch;
int
exchange;
int
len;
exchange
=
0
;
len
=
strlen(
string
);
i
=
i
%
len;
if
(
0
==
i )
return
string
;
int
start_pos
=
0
;
while
( exchange
<
len )
{
char
ch
=
string
[start_pos];
int
currpos
=
start_pos;
int
nextpos
=
(len
+
currpos
+
i)
%
len;
while
( nextpos
!=
start_pos )
{
string
[currpos]
=
string
[nextpos];
++
exchange;
currpos
=
nextpos;
nextpos
=
(len
+
currpos
+
i)
%
len;
}
cout
<<
string
<<
endl;
string
[currpos]
=
ch;
++
exchange;
++
start_pos;
}
return
string
;
}
int
main()
{
char
string
[
7
]
=
{
'
a
'
,
'
b
'
,
'
h
'
,
'
d
'
,
'
h
'
,
'
s
'
}
;
cout
<<
string
<<
endl;
char
*
s;
s
=
string_cyclicshift_v2(
string
,
4
);
cout
<<
s
<<
endl;
return
0
;
}
要求時間復雜度空間復雜度都盡可能的低。
時間復雜度 O(n), 空間復雜度O(1),常量時間。
http://blog.csdn.net/zdl1016/archive/2009/09/21/4575309.aspx
posted on 2009-09-28 23:02
life02
閱讀(1204)
評論(1)
編輯
收藏
引用
所屬分類:
算法
評論
#
re: 字符串循環移位 - 編程珠璣的一道題(轉)[未登錄]
2011-01-14 20:31
yy
for (int i = 0; i < str_len; i++)
new_str[i] = old_str[(i+offset)%len];
回復
更多評論
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
【推薦】100%開源!大型工業跨平臺軟件C++源碼提供,建模,組態!
相關文章:
字符串循環移位 - 編程珠璣的一道題(轉)
堆排序
算法的力量(轉李開復)---適合計算機專業新生
把整數分解為連續整數之和(轉)
memcpy代碼
linklist 直接插入排序
shell排序
網站導航:
博客園
IT新聞
BlogJava
博問
Chat2DB
管理
Powered by:
C++博客
Copyright © life02
久久91精品综合国产首页
|
久久亚洲中文字幕精品一区
|
亚洲AV无码一区东京热久久
|
午夜欧美精品久久久久久久
|
日本久久久久久中文字幕
|
久久嫩草影院免费看夜色
|
久久精品一区二区三区AV
|
国产精品久久久久久福利漫画
|
国产精品久久久久一区二区三区
|
欧美精品丝袜久久久中文字幕
|
久久国产一区二区
|
久久强奷乱码老熟女网站
|
久久99精品久久久久久久不卡
|
久久久久99精品成人片牛牛影视
|
伊人久久大香线蕉综合Av
|
国产精品久久自在自线观看
|
色综合久久中文字幕综合网
|
久久综合九色综合精品
|
亚洲愉拍99热成人精品热久久
|
久久精品亚洲乱码伦伦中文
|
久久久久久毛片免费播放
|
伊人久久大香线蕉无码麻豆
|
亚洲成人精品久久
|
性欧美丰满熟妇XXXX性久久久
|
久久久久国产
|
久久精品成人免费国产片小草
|
99久久777色
|
国产成人久久精品一区二区三区
|
国产精品久久久久久久久久影院
|
久久人人爽人爽人人爽av
|
伊人丁香狠狠色综合久久
|
国产99精品久久
|
伊人久久大香线蕉av不变影院
|
久久久久免费精品国产
|
7国产欧美日韩综合天堂中文久久久久
|
亚洲国产精品狼友中文久久久
|
伊人色综合久久天天
|
久久午夜电影网
|
国产精品99久久久久久董美香
|
91精品国产综合久久香蕉
|
色成年激情久久综合
|