Created
November 23, 2017 14:03
-
-
Save MuhammadJahidHasan/00491abbfed5694cb31dd8f6ec9a2b5c to your computer and use it in GitHub Desktop.
How to convert string to integer and integer to string in c++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cmath> | |
#include <cstdio> | |
#include <vector> | |
#include <string> | |
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
int main() { | |
int a,b,c,val,co=0; | |
string s,revs; | |
cin>>a>>b>>c; | |
for(int i=min(a,b);i<=max(a,b);i++){ | |
s= to_string(i); | |
reverse(s.begin(), s.end()); | |
val=atoi(s.c_str()); | |
if(abs(i-val)%c==0) | |
co++; | |
} | |
cout<<co; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment