Title description
Determine whether a positive integer is two digits (that is, greater than or equal to 10 and less than or equal to 99).
Mr. Garlic: It's very simple, come and pass it!
Input format
A positive integer, no more than 1000.
Output format
One line. If the positive integer is a two-digit number, output 1; otherwise, output 0.
Sample Input
54
Sample Output
1
Ideas
It feels like there is nothing to say, just to judge whether a number is a two-digit number.
C language code:
#include<stdio.h>
int main()
{
int n;
scanf("%d", &n);
if(n / 100 == 0 && n / 10 != 0) printf("1");
else printf("0");
return 0;
}
C++ code:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
while(cin >> n)
if(n >= 10 && n < 100) cout << "1" << endl;
else cout << "0" << endl;
return 0;
}