Codeforces 110A. Nearly Lucky Number Solution
Solve in C++:
#include<iostream>
#include<string.h>
using namespace std;
main()
{
char s[1000];
int l,i,f=0;;
while(cin>>s)
{
l=strlen(s);
for(i=0; i<l; i++)
{
if((s[i]=='4')||(s[i]=='7'))
{
f++;
}
}
if(f==4||f==7)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
f=0;
}
}
#include<iostream>
#include<string.h>
using namespace std;
main()
{
char s[1000];
int l,i,f=0;;
while(cin>>s)
{
l=strlen(s);
for(i=0; i<l; i++)
{
if((s[i]=='4')||(s[i]=='7'))
{
f++;
}
}
if(f==4||f==7)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
f=0;
}
}
No comments