Substring

xiaoxiao2021-03-05  28

Write a function int found (CHAR S [], CHAR T []), the function looks for string t in string s, if found, return the position (integer value) in the string S in the string S; otherwise Return -1. Note: This function is implemented with an array mode and a two cycle.

#include using namespace std; int fixed (char s) {int LEN1 = Strlen (s), len2 = strlen (t), i = 0, j = 0, k; IF ( LEN1

============================================================================================================================================================================================================= ==========================

#include using namespace std; int fixed (char * p = str1, * p1 = str2, * q; while (* p) {if (* p == * p1) {Q = p; do {if (* p == * p1) P , p1 ; else {p1 = str2; break;}} while (* p1 && * p); if (! * P1) Return Q-STR1 1 Else P ;} return 0;} int main () {char str1 [] = "abcc", str2 [] = "abc"; cout << Find (str1, str2) << Endl; system ("pause" RETURN 0;}

转载请注明原文地址:https://www.9cbs.com/read-35655.html

New Post(0)