-
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.
Added 2 problems to Operator & Expression Chapter
- Loading branch information
1 parent
afe3008
commit d01dc7e
Showing
3 changed files
with
98 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ mathjax-support = true | |
[output.html.code.hidelines] | ||
python = "~" | ||
c = "~" | ||
hint = "~" |
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 +1,97 @@ | ||
# Operator & Expression | ||
|
||
|
||
## Problems | ||
* ***Click on the title of the problem to submit your solution before looking at our solution.*** | ||
* ***We discourage looking at our solution before attempting to solve it by yourself first.*** | ||
|
||
1. **[Simple Calculator](https://vjudge.net/problem/Gym-287306C)** | ||
|
||
Given two numbers X and Y. Print the summation and multiplication and subtraction of these 2 numbers. | ||
|
||
***Input*** | ||
|
||
Only one line containing two separated numbers \\(X, Y (1 ≤ X, Y ≤ 10 ^ 5)\\) | ||
|
||
***Output*** | ||
|
||
Print 3 lines that contain the following in the same order: | ||
|
||
1. "\\(X + Y =\\) **summation result**" without quotes. | ||
2. "\\(X * Y =\\) **multiplication result**" without quotes. | ||
3. "\\(X - Y =\\) **subtraction result**" without quotes. | ||
|
||
***Examples*** | ||
|
||
Input | ||
``` | ||
5 10 | ||
``` | ||
Output | ||
``` | ||
5 + 10 = 15 | ||
5 * 10 = 50 | ||
5 - 10 = -5 | ||
``` | ||
***Notes*** | ||
**Be careful with spaces.** | ||
Hint: | ||
```hint | ||
Press the eye icon to reveal hint. | ||
~ Use long long int instead of int | ||
~ Don't forget to use the designated format specifier for long long int (%lld) | ||
``` | ||
**Solution** | ||
```c | ||
// Press the eye icon to reveal solution. | ||
~#include <stdio.h> | ||
~int main() | ||
~{ | ||
~ long long x, y; | ||
~ | ||
~ scanf("%lld %lld", &x, &y); | ||
~ | ||
~ printf("%lld + %lld = %lld\n", x, y, x + y); | ||
~ printf("%lld * %lld = %lld\n", x, y, x * y); | ||
~ printf("%lld - %lld = %lld\n", x, y, x - y); | ||
~ | ||
~ return 0; | ||
~} | ||
``` | ||
2. **[Difference](https://vjudge.net/problem/Gym-287306D)** | ||
Hint: | ||
```hint | ||
Press the eye icon to reveal hint. | ||
~ Use long long int instead of int | ||
~ Don't forget to use the designated format specifier for long long int (%lld) | ||
``` | ||
**Solution** | ||
```c | ||
// Press the eye icon to reveal solution. | ||
~#include <stdio.h> | ||
~int main() | ||
~{ | ||
~ long long a, b, c, d, x; | ||
~ | ||
~ scanf("%lld %lld %lld %lld", &a, &b, &c, &d); | ||
~ | ||
~ x = (a * b) - (c * d); | ||
~ | ||
~ printf("Difference = %lld\n", x); | ||
~ | ||
~ 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