/*Write a program to test two strings to see if the first string is contained in the second string. If the string "PEN" is contained in the string "independent"*/#include<stdio.h>#include<string.h>voidMain () {Chara[ -]; Charb[ -]; intI, J; intnum=0; printf ("Please enter the first string: \ n"); scanf ("%s",&a); printf ("Please enter a second string: \ n"); scanf ("%s",&b); for(i=0; I<strlen (a); i++) { for(j=0; J<strlen (b); J + +) { if(a[i]==B[j]) {i++; Num+=1; } } } if(Strlen (a) = =num) {printf ("the first string character is contained in the second string character."); } Else{printf ("the first string is not included in the second string"); } }
/*find "ASDFJVJADSFFVAADFKFASAFFDSASDFFADSAFAFSAFDADSFAAFD" the number of AF in the string*/#include<stdio.h>#include<string.h>voidMain () {Chara[]="ASDFJVJADSFFVAADFKFASAFFDSASDFFADSAFAFSAFDADSFAAFD"; intI, J; intnum=0; for(i=0; I<strlen (a)-1; i++) { if(a[i]=='a') { if(a[i+1]=='F') {num+=1; }}} printf ("Total%d af\n", num); }
/*Enter any string, such as: "ABDEE23DJFD343DPODDFE4CDD5CCV!23RR". Takes out all the letters in the string to form a new string. The order cannot be changed! and turn the uppercase letters into lowercase, lowercase letters to uppercase! */#include<stdio.h>#include<string.h>voidMain () {Chara[ -]; inti; printf ("Please enter a string: \ n"); scanf ("%s",&a); for(i=0; I<strlen (a); i++) { if(a[i]>='a'&& a[i]<='Z') {printf ("%c", a[i]- +); } Else if(a[i]>='A'&& a[i]<='Z') {printf ("%c", a[i]+ +); } } }
819 C language Jobs