Commit 32205317 authored by Šmelko Adam Mgr.'s avatar Šmelko Adam Mgr.
Browse files

Add Ukol and priklady.

parent f3d7d6aa
......@@ -31,3 +31,4 @@ Deadliny:
| Názov | Deadline | Zadanie | Odovzdať do |
| ------ | ------ | ------ | ------ |
| Násobilka | 05.10.2021 23:59 | Pre každý číselný argument programu vypíšte malú násobilku na samostatný riadok. | GitLab Repozitár |
| Súčet | 12.10.2021 | Spočítajte súčet všetkých čísel nájdených v texte zo štandardného vstupu. Uvažujte len postupnost cifier, ktoré sú oddelené zľava a zprava znakmi '.', '!', '?', whitespaces alebo koniec/začiatok vstupu. | GitLab Repozitár |
\ No newline at end of file
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
void copy(std::istream& from, std::ostream& to)
{
while (true)
{
char c = from.get();
if (from.eof())
{
return;
}
else if (from.fail())
{
std::cout << "Something bad happened" << std::endl;
return;
}
to << c;
}
}
int main(int argc, char** argv)
{
std::vector<std::string> args(argv, argv + argc);
if (args.size() == 1 || args.size() > 3)
{
std::cout << "Bad number of params" << std::endl;
return 1;
}
std::string in_file = args[1];
std::ifstream ifs;
ifs.open(in_file);
if (!ifs.good())
{
std::cout << "Could not open input file" << std::endl;
return 1;
}
if (args.size() == 3)
{
std::string out_file = args[2];
std::ofstream ofs(out_file);
if (!ofs.good())
{
std::cout << "Could not open output file" << std::endl;
return 1;
}
copy(ifs, ofs);
}
else
{
copy(ifs, std::cout);
}
std::cout << "Done" << std::endl;
return 0;
}
\ No newline at end of file
#include <vector>
#include <chrono>
#include <thread>
#include <iostream>
void f(std::vector<int>/*&*/ v, size_t depth)
{
std::cout << "Depth: " << depth << std::endl;
if (depth > 1'000'000)
return;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment