Arild just turned 1 year old, and is currently learning how to count. His favorite thing to count is how many mouthfuls he has in a meal: every time he gets a bite, he will count it by saying the number out loud.
Unfortunately, talking while having a mouthful sometimes causes Arild to mumble incomprehensibly, making it hard to know how far he has counted. Sometimes you even suspect he loses his count! You decide to write a program to determine whether Arild’s counting makes sense or not.
Input
The first line of input contains an integer n (1≤n≤1000), the number of bites Arild receives. Then second line contains n space-separated words spoken by Arild, the i’th of which is either a non-negative integer ai (0≤ai≤10000) or the string “mumble”.
Output
If Arild’s counting might make sense, print the string “makes sense”. Otherwise, print the string “something is fishy”.
Sample Input 1 Sample Output 1
5
1 2 3 mumble 5
makes sense
Sample Input 2 Sample Output 2
8
1 2 3 mumble mumble 7 mumble 8
something is fishy
Sample Input 3 Sample Output 3
3
mumble mumble mumble
makes sense
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 7;
int a[maxn];
string s[maxn];//字符串数组
int main()
{
int flag = 1;
int n;
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> s[i];//输入字符串。
}
for (int i = 1; i <= n; i++)
{
if (s[i] == "mumble")
continue;
if (isdigit(s[i][0]))//判断(注:isdigit仅能将字符转化为数字。)
{
int num = stoi(s[i]);//将字符串转化为数字。//注:此函数在c++11中无法通过编译。stoi是将字符转化为数字。
if (num != i)
flag = 0;//不等于i无法成立。
}
}
if (flag)
cout << "makes sense" << endl;
else
cout << "something is fishy" << endl;
return 0;
}