
11.03.2010, 12:41
|
|
Участник форума
Регистрация: 26.05.2007
Сообщений: 191
С нами:
9980126
Репутация:
9
|
|
2sledopit2
Держи быдло код, работает
Код:
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
void strstr(int &a, int &b);
void strstr(char *str, char *buf);
int main()
{
setlocale(LC_ALL,"Russian");
char s1[80]="Hellow word";
char s2[80]="word";
int i,j;
cout<<"Введите два числа: ";
cin>>i>>j;
strstr(i,j);//Cравнение двух чисел
//теперь рассмотрим поиск подстроки в строке
strstr(s1,s2);
return 0;
}
void strstr(int &a, int &b)
{
if(a>b) cout<<"Первое число больше второго";
else cout<<"Второе число больше первого";
cout<<endl;
}
void strstr(char *str, char *buf)
{
char *p;
char *q;
for(int i=0; str[i]; i++)
{
p=&str[i];
q=buf;
while(*q && *q==*p)
{
p++;
q++;
}
}
cout<<q;
}
|
|
|