Skip to content

Commit

Permalink
tab => 4 spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
orazaro committed Feb 16, 2012
1 parent cbaf88a commit 23df6a3
Show file tree
Hide file tree
Showing 44 changed files with 1,218 additions and 1,218 deletions.
4 changes: 2 additions & 2 deletions 00-00.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

int main()
{
std::cout << "Hello, world!" << std::endl;
return 0;
std::cout << "Hello, world!" << std::endl;
return 0;
}
4 changes: 2 additions & 2 deletions 00-02.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

int main()
{
std::cout << "This (\") is a quote, and this (\\) is a backslash" << std::endl;
return 0;
std::cout << "This (\") is a quote, and this (\\) is a backslash" << std::endl;
return 0;
}
4 changes: 2 additions & 2 deletions 00-03.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

int main()
{
std::cout << "a\tb\t\t\t\tc" << std::endl;
return 0;
std::cout << "a\tb\t\t\t\tc" << std::endl;
return 0;
}
8 changes: 4 additions & 4 deletions 00-04.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

int main()
{
std::cout <<"\
std::cout <<"\
// a small C++ program\n\
#include <iostream>\n\
\n\
int main()\n\
{\n\
std::cout << \"Hello, world!\" << std::endl;\n\
return 0;\n\
std::cout << \"Hello, world!\" << std::endl;\n\
return 0;\n\
}" << std::endl;
return 0;
return 0;
}
10 changes: 5 additions & 5 deletions 01.00.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

int main()
{
std::cout << "Please enter your first name: ";
std::cout << "Please enter your first name: ";

std::string name;
std::cin >> name;
std::string name;
std::cin >> name;

std::cout << "Hello, " << name << "!" << std::endl;
return 0;
std::cout << "Hello, " << name << "!" << std::endl;
return 0;
}
32 changes: 16 additions & 16 deletions 01.01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@

int main()
{
std::cout << "Please enter your first name: ";
std::cout << "Please enter your first name: ";

std::string name;
std::cin >> name;
const std::string greeting = "Hello, " + name + "!";
const std::string spaces(greeting.size(),' ');
const std::string second = "* " + spaces + " *";
const std::string first(second.size(),'*');
std::cout
<< first << std::endl
<< second << std::endl
<< "* " << greeting << " *" << std::endl
<< second << std::endl
<< first << std::endl
;
std::string name;
std::cin >> name;
const std::string greeting = "Hello, " + name + "!";
const std::string spaces(greeting.size(),' ');
const std::string second = "* " + spaces + " *";
const std::string first(second.size(),'*');
std::cout
<< first << std::endl
<< second << std::endl
<< "* " << greeting << " *" << std::endl
<< second << std::endl
<< first << std::endl
;

return 0;
return 0;
}
58 changes: 29 additions & 29 deletions 02-00.cpp
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;
}
70 changes: 35 additions & 35 deletions 02-01.cpp
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;
}
52 changes: 26 additions & 26 deletions 02-05.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,33 @@ using std::cin;

int main()
{
const int width = 10;
const int height = 4;
const int width = 10;
const int height = 4;

cout << "square" << endl;
for(int i = 0; i < height; ++i) {
for(int j = 0; j < height; ++j)
cout << '*';
cout << endl;
}
cout << "rectangle" << endl;
for(int i = 0; i < height; ++i) {
for(int j = 0; j < width; ++j)
cout << '*';
cout << endl;
}
cout << "triangle" << endl;
for(int i = 0; i < height; ++i) {
for(int j = 0; j <= i; ++j)
cout << '*';
cout << endl;
}
cout << "square" << endl;
for(int i = 0; i < height; ++i) {
for(int j = 0; j < height; ++j)
cout << '*';
cout << endl;
}
cout << "rectangle" << endl;
for(int i = 0; i < height; ++i) {
for(int j = 0; j < width; ++j)
cout << '*';
cout << endl;
}
cout << "triangle" << endl;
for(int i = 0; i < height; ++i) {
for(int j = 0; j <= i; ++j)
cout << '*';
cout << endl;
}

int i = 0;
while (i < 10) {
i += 1;
std::cout << i << std::endl;
}
int i = 0;
while (i < 10) {
i += 1;
std::cout << i << std::endl;
}

return 0;
return 0;
}
6 changes: 3 additions & 3 deletions 02-07.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

int main()
{
for(int i = 10; i >= -5; --i)
std::cout << i << std::endl;
return 0;
for(int i = 10; i >= -5; --i)
std::cout << i << std::endl;
return 0;
}
10 changes: 5 additions & 5 deletions 02-08.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

int main()
{
int product = 1;
for(int i = 1; i < 10; ++i)
product *= i;
std::cout << product << std::endl;
return 0;
int product = 1;
for(int i = 1; i < 10; ++i)
product *= i;
std::cout << product << std::endl;
return 0;
}
20 changes: 10 additions & 10 deletions 02-09.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

int main()
{
std::cout << "Please, enter two numbers: ";
int i1, i2;
std::cin >> i1 >> i2;
std::cout << "Please, enter two numbers: ";
int i1, i2;
std::cin >> i1 >> i2;

std::string op = "=";
if(i1 > i2)
op = ">";
else if(i2 > i1)
op = "<";
std::string op = "=";
if(i1 > i2)
op = ">";
else if(i2 > i1)
op = "<";

std::cout << i1 << " " << op << " " << i2 << std::endl;
std::cout << i1 << " " << op << " " << i2 << std::endl;

return 0;
return 0;
}
Loading

0 comments on commit 23df6a3

Please sign in to comment.