Skip to content

Commit

Permalink
Change markdown heading for proper rendering in browser.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanychev committed May 6, 2017
1 parent 21598fa commit 17a1ef5
Show file tree
Hide file tree
Showing 9 changed files with 208 additions and 208 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##C++ Primer 5 Answers(C++11/14)
## C++ Primer 5 Answers(C++11/14)

[![GitHub issues](https://img.shields.io/github/issues/Mooophy/Cpp-Primer.svg)](https://github.com/Mooophy/Cpp-Primer/issues)
[![GitHub license](https://img.shields.io/badge/license-CC0-blue.svg)](https://raw.githubusercontent.com/Mooophy/Cpp-Primer/master/LICENSE)
Expand Down
54 changes: 27 additions & 27 deletions ch01/README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
##Exercise 1.1
## Exercise 1.1

> Review the documentation for your compiler and determine what file naming convention it uses. Compile and run the main program from page 2.
* [GCC and File Extensions](http://labor-liber.org/en/gnu-linux/development/extensions)
* [File Types Created for Visual C++ Projects](https://msdn.microsoft.com/en-us/library/3awe4781.aspx)

##Exercise 1.2
## Exercise 1.2

> Exercise 1.2: Change the program to return -1. A return value of -1 is often treated as an indicator that the program failed. Recompile and rerun your program to see how your system treats a failure indicator from main.
###Windows
### Windows

![windows](https://db.tt/DIJd9eZb)

###Linux
### Linux

![linux](https://db.tt/lhzXhpCt)

**255**? why? please look at [this](http://www.tldp.org/LDP/abs/html/exitcodes.html)

##Exercise 1.3
## Exercise 1.3
> Write a program to print Hello, World on the standard output.
```cpp
Expand All @@ -32,7 +32,7 @@ int main()
}
```

##Exercise 1.4
## Exercise 1.4
> Our program used the addition operator, +, to add two numbers. Write a program that uses the multiplication operator, *, to print the product instead.
```cpp
Expand All @@ -49,7 +49,7 @@ int main()
}
```

##Exercise 1.5
## Exercise 1.5

> We wrote the output in one large statement. Rewrite the program to use a separate statement to print each operand.
Expand All @@ -72,7 +72,7 @@ int main()
}
```

##Exercise 1.6
## Exercise 1.6
> Explain whether the following program fragment is legal.
It's illegal.
Expand All @@ -85,7 +85,7 @@ Fixed it: remove the spare semicolons.
std::cout << "The sum of " << v1 << " and " << v2 << " is " << v1 + v2 << std::endl;
```

##Exercise 1.7
## Exercise 1.7

> Compile a program that has incorrectly nested comments.
Expand All @@ -106,7 +106,7 @@ Compiled result(g++):

![result](https://db.tt/CqQKu8GQ)

##Exercise 1.8
## Exercise 1.8

> Indicate which, if any, of the following output statements are legal:
```cpp
Expand Down Expand Up @@ -134,11 +134,11 @@ Output:

/**/ */ /*

##[Exercise 1.9](ex1_9.cpp)
##[Exercise 1.10](ex1_10.cpp)
##[Exercise 1.11](ex1_11.cpp)
## [Exercise 1.9](ex1_9.cpp)
## [Exercise 1.10](ex1_10.cpp)
## [Exercise 1.11](ex1_11.cpp)

##Exercise 1.12
## Exercise 1.12
> What does the following for loop do? What is the final value
of sum?
```cpp
Expand All @@ -149,7 +149,7 @@ sum += i;

the loop sums the numbers from -100 to 100. the final value of sum is zero.

##Exercise 1.13
## Exercise 1.13
> Rewrite the exercises from § 1.4.1 (p. 13) using for loops.
Ex1.9:
Expand Down Expand Up @@ -202,20 +202,20 @@ int main()
}
```

##Exercise 1.14
## Exercise 1.14
> Compare and contrast the loops that used a for with those
using a while. Are there advantages or disadvantages to using either form?

[A similar question on Stack Overflow](http://stackoverflow.com/questions/2950931/for-vs-while-in-c-programming)

##Exercise 1.15
## Exercise 1.15
> Write programs that contain the common errors discussed in
the box on page 16. Familiarize yourself with the messages the compiler
generates.

Nothing to present here.

##Exercise 1.16
## Exercise 1.16

```cpp
#include <iostream>
Expand All @@ -229,27 +229,27 @@ int main()
}
```

##Exercise 1.17
## Exercise 1.17

> What happens in the program presented in this section if the input values are all equal? What if there are no duplicated values?
If the input values are all equal, it will print a line which shows the count of the number you input.

If there are no duplicated values, when different values input, a new line will be printed if you click `Enter`.

##Exercise 1.18
## Exercise 1.18

> Compile and run the program from this section giving it only equal values as input. Run it again giving it values in which no number is repeated.
![run](https://db.tt/F38zExnq)

##Exercise 1.19
## Exercise 1.19

> Revise the program you wrote for the exercises in § 1.4.1 (p. 13) that printed a range of numbers so that it handles input in which the first number is smaller than the second.
[code](https://github.com/pezy/Cpp-Primer/blob/master/ch01/ex1_11.cpp)

##Exercise 1.20
## Exercise 1.20

> http://www.informit.com/title/032174113 contains a copy of Sales_item.h in the Chapter 1 code directory. Copy that file to your working directory. Use it to write a program that reads a set of book sales transactions, writing each transaction to the standard output.
Expand All @@ -258,14 +258,14 @@ If there are no duplicated values, when different values input, a new line will
Note : C++11 flag need to enable.
For GCC and Clang, this can be done with the `-std=c++11`

##Exercise 1.21
## Exercise 1.21
> Write a program that reads two Sales_item objects that have the same ISBN and produces their sum.
The program should check whether the objects have the same ISBN.

[Code](ex1_21.cpp)

##Exercise 1.22
## Exercise 1.22

> Write a program that reads several transactions for the same ISBN. Write the sum of all the transactions that were read.
Expand All @@ -275,15 +275,15 @@ Tips: this program will appear in the section 1.6.

![run](https://db.tt/UlkuvpAS)

##Exercise 1.23
## Exercise 1.23
> Write a program that reads several transactions and counts
how many transactions occur for each ISBN.

Tip: please review the `1.4.4`.

[Here](ex1_23.cpp) is the code.

##Exercise 1.24
## Exercise 1.24
> Test the previous program by giving multiple transactions
representing multiple ISBNs. The records for each ISBN should be grouped
together.
Expand All @@ -292,7 +292,7 @@ together.

![run](https://db.tt/EeDI7lvN)

##Exercise 1.25
## Exercise 1.25
> Using the Sales_item.h header from the Web site,
compile and execute the bookstore program presented in this section.

Expand Down
Loading

0 comments on commit 17a1ef5

Please sign in to comment.