codeforces 58A solution in c/c++
// 58A.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
# include<string>
using namespace std;
int main()
{
string anis;
string aa[100];
cin >> anis;
int j = 0,hh=0,v;
int ee = 0, ll = 0, oo = 0;
v = anis.size();
for (int i = 0;i < v;i++)
{
if (anis[i] == 'h'&&hh==0)
{
aa[j] ='h';
hh++;
j++;
}
else if (anis[i] == 'e'&&ee== 0&&hh==1)
{
aa[j] = 'e';
ee++;
j++;
}
else if (anis[i] == 'l'&&ll <= 1&&ee==1)
{
aa[j] ='l';
ll++;
j++;
}
else if (anis[i] == 'o'&&oo == 0&&ll==2)
{
aa[j] = 'o';
oo++;
j++;
}
}
if (aa[0]=="h"&&aa[1]=="e"&&aa[2]=="l"&&aa[3]=="l"&&aa[4]=="o")
{
cout << "YES";
}
else
{
cout << "NO";
}
return 0;
}
//
#include <iostream>
# include<string>
using namespace std;
int main()
{
string anis;
string aa[100];
cin >> anis;
int j = 0,hh=0,v;
int ee = 0, ll = 0, oo = 0;
v = anis.size();
for (int i = 0;i < v;i++)
{
if (anis[i] == 'h'&&hh==0)
{
aa[j] ='h';
hh++;
j++;
}
else if (anis[i] == 'e'&&ee== 0&&hh==1)
{
aa[j] = 'e';
ee++;
j++;
}
else if (anis[i] == 'l'&&ll <= 1&&ee==1)
{
aa[j] ='l';
ll++;
j++;
}
else if (anis[i] == 'o'&&oo == 0&&ll==2)
{
aa[j] = 'o';
oo++;
j++;
}
}
if (aa[0]=="h"&&aa[1]=="e"&&aa[2]=="l"&&aa[3]=="l"&&aa[4]=="o")
{
cout << "YES";
}
else
{
cout << "NO";
}
return 0;
}
Comments
Post a Comment