Advertisement
evgenko

function(stroki(b))

Jun 6th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. void poz_max_slova(char stroka[],int&probel_do_slova,int&probel_posle_slova)
  5. {
  6.     int i=0;
  7.     int probel_do_slova_new=0;
  8.     while (stroka[i]!=0)
  9.     {
  10.         if (stroka[i]==32)
  11.             probel_do_slova_new=i;
  12.         if (i-probel_do_slova_new>probel_posle_slova-probel_do_slova)
  13.         {
  14.             probel_do_slova=probel_do_slova_new;
  15.             probel_posle_slova=i;
  16.         }
  17.     i++;
  18.     }
  19. }
  20. void vivod_slova(char stroka[],int probel_do_slova,int&probel_posle_slova)
  21. {
  22.     for (int i=0;i<=probel_posle_slova-probel_do_slova;i++)
  23.     {
  24.         cout<<stroka[probel_do_slova+i];
  25.     }
  26. }
  27. int main()
  28. {
  29.     char stroka[100];
  30.     int prdoslova=0;
  31.     int prposlslova=0;
  32.     cin.getline(stroka,100);
  33.     poz_max_slova(stroka,prdoslova,prposlslova);
  34.     vivod_slova(stroka,prdoslova,prposlslova);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement