輸入乙個字串並使其反序輸出

2021-08-14 03:19:37 字數 638 閱讀 3206

c語言寫法:

#include "stdio.h"

#include "string.h"

#include "math.h"

void

reverse(char *str)

}int main(void)

; printf("請輸入一行字串:");

//這裡不用scanf()是因為scanf()一次只能讀取乙個連續字串,遇到空格則會捨棄空格後的其他字元

fgets(str, 1024, stdin);

reverse(str);

return

0;}

c++寫法

這裡用了更複雜的方法(遞迴),實際上直接使用for_each()函式即可

#include 

#include

#include

using

namespace

std;

void show(string::iterator _begin, string::iterator _end)

}void reverse(string &s)

int main()

在乙個字串中尋找另外乙個字串

在乙個字串中尋找另外乙個字串 public class text foundit true break test system.out.println foundit?found it didn t find it 該段程式有點難以理解,主要就是if語句的理解,if searchme.charat ...

php判斷乙個字串包含另乙個字串

a 58252,58253 如果 a 中存在 b,則為 true 否則為 false。b 58253 if strpos a,b false else 查詢字串在陣列中出現的次數 array array 1,hello 1,world hello 11 計算 string在 array 需為陣列 中...

SQL 判斷乙個字串是否在另外乙個字串中

eg str1 admin str2 1234,123admin,xcxx 比較str1是否在str2中 用常用的charindex,返回肯定是有值的,這裡自己動手寫乙個方法 檢查乙個字串是否在另外乙個字串中數,另外乙個字串元素用,隔開 create function dbo checkstrina...