소개글
1. Write the following function
int strFind(char *s, char* t, int sLength, int tLength, int startIndex);
Find the starting position of target string in the source string after startIndex
If there is no result, return -1
Examples:
strFind(“hamburger”, “burger”, 9, 6, 0) ->return 3 (not 4)
strFind(“comecomecome”, “come”, 12, 4, 0) -> return 0
strFind(“comecomecome”, “come”, 12, 4, 2) -> return 4 (not 0)
strFind(“ababab”, “abc”, 6, 3, 0) -> return -1
2. Sort three integer values
Three values are entered as pointer
You may need to make new variable(s) in sort3 function
Examples:
void main() { int a, b, c; a = 3; b = 2; c = 1; sort3(&a, &b, &c); printf(“After sort3 : %d %d %d”, a, b, c);}
Result :
목차
1. introduction
2.source code
3. result
본문내용
include<stdio.h>
int strFind(char *s, char *t, int sLength, int tLength, int startIndex);
void sort3(int *n1, int *n2, int *n3);
int main(void)
{
char *fullname=NULL;
char *partname=NULL;
int index=-1;
int a,b,c;
index=strFind("kojaehyun", "jaehyun",9,7,0);
printf("Result of strFind( "kojaehyun", "jaehyun", 9, 7, 0 )t is %d n", index);
index=strFind("comecomecome", "comecome",12,4,2);
printf("Result of strFind( "comecomecome", "come", 12, 8, 2 )t is %d n", index);
index=strFind("Network", "ya",7,2,2);
printf("Result of strFind( "Network", "ya", 7, 2, 2 )t is %d n", index);
index=strFind("ababab", "abc",6,3,0);
printf("Result of strFind( "ababab", "abc", 6, 3, 0 )t is %d n", index);
printf( "n" );
a = 3, b = 2, c = 1;
printf( "Before sort3: %d %d %dn", a, b, c );
sort3( &a, &b, &c );
) 같은 문자가 있을 경우 이번엔 target 문자열이 source 문자열에 포함되는지 확인한다.
이번엔 tLength를 이용하여 source 문자열과 target 문자열의 각각의 문자를 하나씩 비교한다.
->모두 같으면 return i (여기서 i는 target 문자의 첫번째 문자가 일치하는 sorurce문자열의 index)
참고 자료
없음