Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- #include <iomanip>
- #include <sstream>
- double string_to_double( const std::string& s )
- {
- std::istringstream i(s);
- double x;
- if (!(i >> x))
- return 0;
- return x;
- }
- using namespace std;
- int main()
- {
- double TAB[1000];
- int max_length=0;
- int liczba=0;
- string liczby;
- cout << "How many numbers are you inputting into array: ";
- cin >> liczba;
- for (int a=0; a<=liczba; a++)
- {
- cin >> liczby;
- if (liczby.length() > max_length){max_length=liczby.length();}
- TAB[a]=string_to_double (liczby);
- }
- cout << endl;
- for (int a=0; a<=liczba; a++)
- {
- }
- for (int a=0; a<=liczba; a++)
- {
- cout << setw(max_length) << TAB[a] << endl;
- }
- cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement