SHARE
TWEET

Untitled

a guest Oct 22nd, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     string name, surname;
  9.     int tel, telc, longest;
  10.  
  11.     cout << "Give me your name" << endl;
  12.     cin >> name;
  13.     cout << "Give me your surname" << endl;
  14.     cin >> surname;
  15.     cout << "Give me your tel. num." << endl;
  16.     cin >> tel;
  17.     telc = tel;
  18.     unsigned int numberOfDigits = 0;
  19.     do {
  20.          ++numberOfDigits;
  21.          telc /= 10;
  22.     } while (telc);
  23.     longest = numberOfDigits;
  24.     if (name.length() > longest)
  25.         longest = name.length();
  26.     if (surname.length() > longest)
  27.         longest = surname.length();
  28.     for (int i = 1; i < longest + 3; i++)
  29.         cout << "*";
  30.         cout << endl;
  31.     cout << "*" << name;
  32.     for (int i = name.length(); i < longest; i++)
  33.         cout << " ";
  34.     cout << "*" << endl << "*" << surname;
  35.     for (int i = surname.length(); i < longest; i++)
  36.         cout << " ";
  37.     cout << "*" << endl << "*" << tel;
  38.     for (int i = numberOfDigits; i < longest; i++)
  39.         cout << " ";
  40.     cout << "*" << endl;
  41.     for (int i = 1; i < longest + 3; i++)
  42.         cout << "*";
  43.         cout << endl;
  44.     return 0;
  45. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top