forked from orazaro/accelerated
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
orazaro
committed
Feb 16, 2012
1 parent
cbaf88a
commit 23df6a3
Showing
44 changed files
with
1,218 additions
and
1,218 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,40 @@ | ||
#include <iostream> | ||
#include <string> | ||
|
||
using std::cout; using std::endl; | ||
using std::cout; using std::endl; | ||
using std::cin; | ||
|
||
int main() | ||
{ | ||
cout << "Please enter your first name: "; | ||
std::string name; | ||
cin >> name; | ||
const std::string greeting = "Hello, " + name + "!"; | ||
cout << "Please enter your first name: "; | ||
std::string name; | ||
cin >> name; | ||
const std::string greeting = "Hello, " + name + "!"; | ||
|
||
const int pad = 1; | ||
const int rows = pad * 2 + 3; | ||
const std::string::size_type cols = greeting.size() + pad * 2 + 2; | ||
const int pad = 1; | ||
const int rows = pad * 2 + 3; | ||
const std::string::size_type cols = greeting.size() + pad * 2 + 2; | ||
|
||
cout << endl; | ||
// invariant: r rows written so far | ||
for(int r = 0; r != rows; ++r) { | ||
std::string::size_type c = 0; | ||
// invariant: c columns written so far | ||
while( c != cols) { | ||
if(r == pad+1 && (int)c == pad+1) { | ||
cout << greeting; | ||
c += greeting.size(); | ||
} else { | ||
if( r == 0 || r == rows-1 || c == 0 || c == cols-1 ) | ||
cout << '*'; | ||
else | ||
cout << ' '; | ||
++c; | ||
} | ||
} | ||
cout << endl; | ||
} | ||
cout << endl; | ||
// invariant: r rows written so far | ||
for(int r = 0; r != rows; ++r) { | ||
std::string::size_type c = 0; | ||
// invariant: c columns written so far | ||
while( c != cols) { | ||
if(r == pad+1 && (int)c == pad+1) { | ||
cout << greeting; | ||
c += greeting.size(); | ||
} else { | ||
if( r == 0 || r == rows-1 || c == 0 || c == cols-1 ) | ||
cout << '*'; | ||
else | ||
cout << ' '; | ||
++c; | ||
} | ||
} | ||
cout << endl; | ||
} | ||
|
||
return 0; | ||
return 0; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,48 @@ | ||
#include <iostream> | ||
#include <string> | ||
|
||
using std::cout; using std::endl; | ||
using std::cout; using std::endl; | ||
using std::cin; | ||
|
||
int main() | ||
{ | ||
cout << "Please enter your first name: "; | ||
std::string name; | ||
cin >> name; | ||
const std::string greeting = "Hello, " + name + "!"; | ||
cout << "Please enter your first name: "; | ||
std::string name; | ||
cin >> name; | ||
const std::string greeting = "Hello, " + name + "!"; | ||
|
||
int pad = 0; | ||
cout << "Pad: "; | ||
cin >> pad; | ||
int pad = 0; | ||
cout << "Pad: "; | ||
cin >> pad; | ||
|
||
cout << endl; | ||
cout << endl; | ||
|
||
const int rows = pad * 2 + 3; | ||
const std::string::size_type cols = greeting.size() + pad * 2 + 2; | ||
const int rows = pad * 2 + 3; | ||
const std::string::size_type cols = greeting.size() + pad * 2 + 2; | ||
|
||
std::string spaces(greeting.size() + pad * 2,' '); | ||
// invariant: r rows written so far | ||
for(int r = 0; r != rows; ++r) { | ||
std::string::size_type c = 0; | ||
// invariant: c columns written so far | ||
while( c != cols) { | ||
if(r == pad+1 && (int)c == pad+1) { | ||
cout << greeting; | ||
c += greeting.size(); | ||
} else if(r != 0 && r != rows-1 && r != pad+1 && c == 1) { | ||
cout << spaces; | ||
c += spaces.size(); | ||
} else { | ||
if( r == 0 || r == rows-1 || c == 0 || c == cols-1 ) | ||
cout << '*'; | ||
else | ||
cout << ' '; | ||
++c; | ||
} | ||
} | ||
cout << endl; | ||
} | ||
std::string spaces(greeting.size() + pad * 2,' '); | ||
// invariant: r rows written so far | ||
for(int r = 0; r != rows; ++r) { | ||
std::string::size_type c = 0; | ||
// invariant: c columns written so far | ||
while( c != cols) { | ||
if(r == pad+1 && (int)c == pad+1) { | ||
cout << greeting; | ||
c += greeting.size(); | ||
} else if(r != 0 && r != rows-1 && r != pad+1 && c == 1) { | ||
cout << spaces; | ||
c += spaces.size(); | ||
} else { | ||
if( r == 0 || r == rows-1 || c == 0 || c == cols-1 ) | ||
cout << '*'; | ||
else | ||
cout << ' '; | ||
++c; | ||
} | ||
} | ||
cout << endl; | ||
} | ||
|
||
return 0; | ||
return 0; | ||
} |
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
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
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
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
Oops, something went wrong.