Определить, сколько раз встречается заданный символ в строке(использование функций).
#include<iostream.h>
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
int vvod(char s[])
{
cout<<"\nВведите строку:\n";
gets(s);
}
int func(char s[])
{
cout<<"\nВведите символ: ";
char h[1];
gets(h);
int kol=0;
int i=0;
while(s[i]!='\0')
{
if (s[i]==h[0])
kol++;
i++;
}
cout <<"\nСимвол встречается "<<kol<<" раз";
}
int main ()
{
setlocale(LC_ALL,"rus");
char c[100];
vvod(c);
func(c);
getch();
}
Комментарии:
Нету комментариев для вывода...