0% found this document useful (0 votes)
24 views1 page

Ptest

P test introduction and tutorial

Uploaded by

asdghf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views1 page

Ptest

P test introduction and tutorial

Uploaded by

asdghf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include<iostream>

#include<string.h>
using namespace std;
void SearchLetter(char*, char*);
int output1;
int main(){
char *input1 = "my name is granar";
char *input2 = "a";
SearchLetter(input1,input2);
}
void SearchLetter(char* input1, char* input2){
int arr[26]={0};
int len = strlen(input1);
int occ1 = -1;
int occ2 = -1;
// int n = 0;
int sum = 0;
int i=0;
for(int i=0;i<len;i++){
if(input1[i] == *input2)
{
if(occ1 == -1) {occ1 = i;}
else {occ2 = i;
}
}
}
int ans = occ2-occ1;
cout<<len<<endl;
cout<<ans<<endl;
if (occ1 == -1) output1=-1;
if(occ2 == -1) output2 = -1;
for(int i=occ1;i<occ2;i++){
if((input1[i]-'a') <=26 && (input1[i]-'a') >=0){
arr[input1[i]-'a']++;
}
}
arr[*input2 - 'a'] = 0;
for(int i=0;i<26;i++){
if(arr[i]>0){
sum++;
}
}
cout<<sum;
return;
}

You might also like