Converted everything to orgmode
converted everything to orgmode and added solution to the README files
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
_This task is a mixed text/programming task. You need to update the content of loop.cpp according to the instruction provided in the file. For the code part, please check the autograder output._
|
||||
|
||||
# Task
|
||||
|
||||
Considering the snippet
|
||||
|
||||
```cpp
|
||||
for (;;) {
|
||||
int i1, i2;
|
||||
std::cin >> i1 >> i2;
|
||||
std::cout << i1 + i2 << "\n";
|
||||
int again;
|
||||
std::cout << "Again? (0/1)\n";
|
||||
std::cin >> again;
|
||||
if (again == 0) break;
|
||||
}
|
||||
```
|
||||
|
||||
1. Describe what it computes.
|
||||
|
||||
1. Decide which of the other two kind of loops would fit better than the one it is currently using, and describe why.
|
||||
|
||||
1. Rewrite the snippet into the loop you specified in (2). This part is autograded. Note: print the control message "Again? (0/1)" using the same format used in the snippet.
|
@@ -1,3 +1,33 @@
|
||||
#+TITLE: Task 2: Loop mix-up: Snippet 2
|
||||
#+AUTHOR: JirR02
|
||||
|
||||
/This task is a mixed text/programming task. You need to update the content of loop.cpp according to the instruction provided in the file. For the code part, please check the autograder output./
|
||||
|
||||
* Task
|
||||
|
||||
Considering the snippet
|
||||
|
||||
#+begin_src cpp
|
||||
for (;;) {
|
||||
int i1, i2;
|
||||
std::cin >> i1 >> i2;
|
||||
std::cout << i1 + i2 << "\n";
|
||||
int again;
|
||||
std::cout << "Again? (0/1)\n";
|
||||
std::cin >> again;
|
||||
if (again == 0) break;
|
||||
}
|
||||
#+end_src
|
||||
|
||||
1. Describe what it computes.
|
||||
|
||||
1. Decide which of the other two kind of loops would fit better than the one it is currently using, and describe why.
|
||||
|
||||
1. Rewrite the snippet into the loop you specified in (2). This part is autograded. Note: print the control message "Again? (0/1)" using the same format used in the snippet.
|
||||
|
||||
* Solution
|
||||
|
||||
#+begin_src cpp
|
||||
#include "loop.h"
|
||||
#include <iostream>
|
||||
|
||||
@@ -46,3 +76,8 @@ void loop() {
|
||||
std::cin >> again;
|
||||
}
|
||||
}
|
||||
#+end_src
|
||||
|
||||
-----
|
||||
|
||||
Made by JirR02 in Switzerland 🇨🇭
|
Reference in New Issue
Block a user