Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sstream>
- #include <iostream>
- #include <cstdlib>
- #include <cstdio>
- #include <cctype>
- using namespace std;
- string convert_to_string(float number)
- {
- stringstream ss;
- ss << number;
- return ss.str();
- }
- float convert_to_number(string s)
- {
- float number;
- stringstream ss (s);
- ss >> number;
- return number;
- }
- int check_to_number(string s)
- {
- int check = 1;
- for (int i = 0; i<s.length(); i++)
- if (!isdigit(s[i]) && s[i] != '.')
- {
- check = 0;
- break;
- }
- return check;
- }
- int main()
- {
- string s;
- float number;
- cin>>number;
- s = convert_to_string(number);
- cout<<s<<endl;
- fflush(stdin);
- getline(cin,s);
- if (check_to_number(s))
- {
- number = convert_to_number(s);
- cout<<number*2;
- }
- else cout<<"This isn't a number !";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement