Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // zadanie_6.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <clocale>
- #include <iostream>
- #include <string>
- using namespace std;
- int kolvo(char a, bool sl)
- {
- int m=0;
- if((sl)&&(a=='5'))
- {
- m=1;
- }
- return m;
- }
- int main()
- {
- setlocale(0, "rus");
- char st[100];
- gets(st);
- int i,n=0,k=0;
- bool slovo=false;
- if (st[0]!=' ')
- slovo=true;
- cout<<"Число - кол-во цифр 5\n";
- for(i=0;i<strlen(st);i++)
- {
- if((st[i-1]==' ')&&(st[i]!=' '))
- {
- slovo=true;
- }
- else
- if((st[i]==' ')&&(st[i-1]!=' '))
- {
- slovo=false;
- n=0;
- }
- n+=kolvo(st[i],slovo);
- k=n;
- if(slovo)
- cout<<st[i];
- if((slovo)&&((st[i+1]==' ')||((i+1)==strlen(st))))
- cout<<" - "<<k<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment