#include <cstdlib>
#include <iostream>
using namespace std;
void Pencocokan(string P, string T,int n,int m,int idx)
{
int i,j;
bool ketemu;
j=0;
i=0;
ketemu=false;
while (i<= n-m && !ketemu) {
j = 1;
};
while ((j<= m) && (P[j]=T[i+j]))
{
j=j+1;
}
if (j=m){
ketemu=true;
}
else{
i=i+1;
}
if (ketemu==true){
idx=i+1;
}
else {
idx = -1;
}
}
int main(int argc, char *argv[])
{
int idx;
Pencocokan("bayu","pamungkas",9,4,idx);
system("PAUSE");
return EXIT_SUCCESS;
}
#include <iostream>
using namespace std;
void Pencocokan(string P, string T,int n,int m,int idx)
{
int i,j;
bool ketemu;
j=0;
i=0;
ketemu=false;
while (i<= n-m && !ketemu) {
j = 1;
};
while ((j<= m) && (P[j]=T[i+j]))
{
j=j+1;
}
if (j=m){
ketemu=true;
}
else{
i=i+1;
}
if (ketemu==true){
idx=i+1;
}
else {
idx = -1;
}
}
int main(int argc, char *argv[])
{
int idx;
Pencocokan("bayu","pamungkas",9,4,idx);
system("PAUSE");
return EXIT_SUCCESS;
}
No comments:
Post a Comment