题目链接:https://www.nowcoder.com/acm/contest/70/A
分析:很简单的水题,透过题目而言,就是比较4的数目和7的数目谁多
代码如下:
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <string>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int main()
{
string str;
int sum=0,sum1=0,l;
cin>>str;
l=str.length();
for(int i=0; i<l; i++)
{
if(str[i]=='4')
sum++;
if(str[i]=='7')
sum1++;
}
if(sum+sum1==0)
{
printf("-1\n");
return 0;
}
if(sum>=sum1)
printf("4\n");
else
printf("7\n");
return 0;
}