Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // { Driver Code Starts
- // Initial Template for C++
- #include <bits/stdc++.h>
- using namespace std;
- // } Driver Code Ends
- // User function Template for C++
- class Solution {
- public:
- int isDigitSumPalindrome(int N) {
- int sum = 0;
- while (N > 0) {
- sum += N % 10;
- N /= 10;
- }
- string ans = to_string(sum);
- string temp = ans;
- reverse(ans.begin(), ans.end());
- if (ans == temp) {
- return 1;
- } else {
- return 0;
- }
- }
- };
- // { Driver Code Starts.
- int main() {
- int t;
- cin >> t;
- while (t--) {
- int N;
- cin >> N;
- Solution ob;
- cout << ob.isDigitSumPalindrome(N) << "\n";
- }
- }
- // } Driver Code Ends
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement