Cześć.
Napisałem program, który oblicza ile razy w danym ciągu wystąpiły obok siebie dwa identyczne znaki i wypisuje je.
Uwaga program musi działać przy użyciu co najmniej dwóch funkcji.
#include<iostream>
using namespace std;
short fun(string text)
{
short arr[50],dlugosc=0,c=0;
while(text[dlugosc++]!=0)
if(text[dlugosc-1]==text[dlugosc])
arr[c++]=text[dlugosc-1];
return c;
}
char fun2(short c)
{
short arr[50];
for(short i=0; i<c; i++)
cout<<arr[i]<<" ";
}
int main()
{
string text;
cin>>text;
fun(text);
fun2(fun(text));
return 0;
}
Program nie działa poprawnie, hmm w czym jest problem?