Advertisement
florin88

Heart/Cuore Valentine's Day/San Valentino

Feb 14th, 2014
1,316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     double x, y, size=10;
  9.     char ch=3;
  10.     string message("     Buon San Valentino!!!");
  11.        
  12.     int print_line = 4;
  13.  
  14.     if (message.length() % 2 != 0) message += " ";
  15.  
  16.     for (x=0;x<size;x++)
  17.     {
  18.         for (y=0;y<=4*size;y++)
  19.         {
  20.             double dist1 = sqrt( pow(x-size,2) + pow(y-size,2) );
  21.             double dist2 = sqrt( pow(x-size,2) + pow(y-3*size,2) );
  22.  
  23.             if (dist1 < size + 0.5 || dist2 < size + 0.5 ) {
  24.                 cout << ch;
  25.             }
  26.             else cout << " ";
  27.         }
  28.         cout<<"\n";
  29.     }
  30.  
  31.     for (x=1;x<2*size;x++)
  32.     {
  33.         for(y=0;y<x;y++) cout << " ";
  34.  
  35.         for (y=0; y<4*size + 1 - 2*x; y++)
  36.         {
  37.             if (x >= print_line - 1 && x <= print_line + 1) {
  38.                 int idx = y - (4*size - 2*x - message.length()) / 2;
  39.                 if (idx < message.length() && idx >= 0) {
  40.                     if (x == print_line) cout<<message[idx];
  41.                     else cout << " ";
  42.                 }
  43.                 else cout << ch;
  44.             }
  45.             else cout << ch;
  46.         }
  47.         cout<<endl;
  48.     }
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement