龙之白云 龙之白云
关注数: 123 粉丝数: 241 发帖数: 4,977 关注贴吧数: 140
求高手把下面这段C++代码转换成C #include #include #include #include using namespace std;bool check(const char map[50][50], const int& m, const int& n, const int& pos_i, const int& pos_j, const char test[], const int& len){ bool is_true; if(pos_i + 1 - len >= 0) { if(pos_j + 1 - len >= 0) { is_true = true; for(int k = 1, i = pos_i-1, j = pos_j-1; k < len; k++, i--, j--) if(map[i][j] != test[k]) is_true = false; if(is_true) return true; } is_true = true; for(int k = 1, i = pos_i-1; k < len; k++, i--) if(map[i][pos_j] != test[k]) is_true = false; if(is_true) return true; if(pos_j + len <= n) { is_true = true; for(int k = 1, i = pos_i-1, j = pos_j+1; k < len; k++, i--, j++) if(map[i][j] != test[k]) is_true = false; if(is_true) return true; } } if(pos_j + 1 - len >= 0) { is_true = true; for(int k = 1, j = pos_j-1; k < len; k++, j--) if(map[pos_i][j] != test[k]) is_true = false; if(is_true) return true; } if(pos_j + len <= n) { is_true = true; for(int k = 1, j = pos_j+1; k < len; k++, j++) if(map[pos_i][j] != test[k]) is_true = false; if(is_true) return true; } if(pos_i + len <= m) { if(pos_j + 1 - len >= 0) { is_true = true; for(int k = 1, i = pos_i+1, j = pos_j-1; k < len; k++, i++, j--) if(map[i][j] != test[k]) is_true = false; if(is_true) return true; } is_true = true; for(int k = 1, i = pos_i+1; k < len; k++, i++) if(map[i][pos_j] != test[k]) is_true = false; if(is_true) return true; if(pos_j + len <= n) { is_true = true; for(int k = 1, i = pos_i+1, j = pos_j+1; k < len; k++, i++, j++) if(map[i][j] != test[k]) is_true = false; if(is_true) return true; } } return false;}void search(const char map[50][50], const int& m, const int& n, const char test[], const int& len, int& pos_i, int& pos_j){ for(int i = 0; i < m; i++) { for(int j = 0; j < n; j++) { if(map[i][j] == test[0]) { if(check(map, m, n, i, j, test, len)) { pos_i = i + 1, pos_j = j + 1; return; } } } }}int main(){ char map[50][50], test[51]; int k, m, n, p, i, j, len; cin >> k; for(k--; k >= 0; k--) { cin >> m >> n; for(i = 0; i < m; i++) { for(j = 0; j < n; j++) { cin >> map[i][j]; map[i][j] = tolower(map[i][j]); } } cin >> p; for(p--; p >= 0; p--) { cin >> test; len = strlen(test); for(i = 0; i < len; i++) test[i] = tolower(test[i]); search(map, m, n, test, len, i, j); cout << i << ' ' << j << endl; } if(k != 0) cout << endl; } getchar(); return 0;}
【百度贴吧之最】 最新最全 (转) 百度第一个注册用户: liuhua (注册时间2003-11-25 09:32) http://hi.baidu.com/liuhua/profile 百度最诡异的ID: admin (注册时间:2005-08-03 19:00 最后访问时间:2003-12-01 13:46) http://passport.baidu.com/?business&aid=6&un=admin#0 ID:baidu 怪异原因同上 http://passport.baidu.com/?business&aid=6&un=baidu#0 ID:yujie 他的注册时间和liuhua同年同月同日同时同分 此ID相传以前是百度员工,后来辞职不干了,据说此人回复过的帖子回复数量和点击率全部清零 http://hi.baidu.com/%C6%EB%D3%F1%BD%DC/profile 这个吧更有意思了,这吧明明就不存在,但是有上面两位高人说话的帖子,而且这吧还有吧主 但是你点进去这个吧,你看看你到哪了? http://post.baidu.com/f?ct=335675392&tn=baiduPostBrowser&sc=2617&z=259&pn=0&rn=50&lm=0&word=%B0%E6%D6%F7%C9%EA%C7%EB#2617 发帖数最多的ID: •小强•(找到相关贴吧贴子544385篇,用时0.044秒) http://post.baidu.com/f?ct=352321536&tn=baiduPostSearch&rn=10&pn=0&lm=65541&kw=&rs2=2&myselectvalue=2&word=%A1%A4%D0%A1%C7%BF%A1%A4 名字最长的ID: 谁再用我心爱的土琵琶弹着一曲东风破 http://post.baidu.com/f?tn=baiduPostSearch&kw=&ct=352321536&lm=65541&rs5=1&rs2=2&sn=&word=&un=%CB%AD%D4%D9%D3%C3%CE%D2%D0%C4%B0%AE%B5%C4%CD%C1%C5%FD%C5%C3%B5%AF%D7%C5%D2%BB%C7%FA%B6%AB%B7%E7%C6%C6&rs1=0&rn=10 最有个性ID:靠你妈了靠你妈了靠你妈靠你妈 还有谁比他的ID更有个性 http://post.baidu.com/f?ct=352321536&tn=baiduPostSearch&rn=10&pn=0&lm=65541&sc=&kw=&rs2=2&myselectvalue=2&word=%BF%BF%C4%E3%C2%E8%C1%CB%BF%BF%C4%E3%C2%E8%C1%CB%BF%BF%C4%E3%C2%E8%BF%BF%C4%E3%C2%E8&submit=%B0%D9%B6%C8%D2%BB%CF%C2&tb=on 百度最强的空间:glegooseek (登陆4天,不在贴吧说一句话的条件下,空间流量过30W.) http://hi.baidu.com/%D7%AA%BD%C7%D3%F6%B5%BD%B0%AE%CF%C2%D4%D8
首页 1 2 下一页