Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- int ans(0), counter(0);
- int tmp;
- for(int i = 0; i < n; ++i)
- {
- cin >> tmp;
- int help = abs(tmp);
- if(help > 9)
- {
- int first_digit(0);
- int last_digit(0);
- last_digit = help % 10;
- while(help > 9)
- {
- help /= 10;
- }
- first_digit = help;
- if(first_digit == last_digit)
- {
- if(ans == 0)
- {
- ans = tmp;
- }
- ++counter;
- }
- }
- }
- if(counter)
- {
- cout << ans << ' ' << counter;
- }
- else
- {
- cout << "NO\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment