Skip to content
Snippets Groups Projects
Commit f5940da1 authored by Tomáš Pachman's avatar Tomáš Pachman
Browse files

edit

parent 8b9b8c21
No related branches found
No related tags found
No related merge requests found
.vscode/
\ No newline at end of file
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "C:\\MinGW\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compiler: C:\\MinGW\\bin\\g++.exe"
}
]
}
\ No newline at end of file
#include <iostream> //+stdio.h v c++
#include <iomanip>
#include <iostream> //+ std::cin, std::cout, std::fixed, std::scientific
#include <iomanip> //+ std::setprecision(), std::setw()
namespace A{
void foo(void){
std::cout << "Bar" << std::endl;
}
namespace A
{
//+ Fce v ruznych namespace (jmenny prostor) mohou mit stejny prototyp (tj. jmeno, navratovy typ a parametry)
void foo(void)
{
std::cout << "Bar" << std::endl;
}
}
namespace B{
void foo(void){
std::cout << "Bar ale v B" << std::endl;
}
namespace B
{
void foo(void)
{
std::cout << "Bar ale v B" << std::endl;
}
}
using namespace std;
namespace mujstd=std;
//+main stejne jako v c
int main(int argc, char *argv){
//+operator proudoveho zapisu <<
//+ cout vypis do terminalu
std::cout << "Hollo PPC" << std::endl;
A::foo();
B::foo();
cout << "Vypis bez std" << endl;
//+ cin nacteni z terminalu
int a,b;
cout << "Zadej dve cisla" << endl;
cin >> a >>b;
if(std::cin.good()){
cout << "Zadal jsi " << a << "a" << b << mujstd::endl;
}
else{
std::cout << "Zopakuj si datove typy" << std::endl;
cout << ((cin.rdstate() & ios_base::badbit) ? "B":"b");
cout << ((cin.rdstate() & ios_base::eofbit) ? "E":"e");
cout << ((cin.rdstate() & ios_base::failbit) ? "F":"f");
cout << endl;
}
double pi=3.14159;
std::cout<<pi<<std::endl;
std::cout<<std::setprecision(3)<<pi<<std::endl;
std::cout<<setw(10)<<pi<<std::endl;
std::cout<< std::fixed<<pi<<std::endl;
std::cout<<std::scientific<<pi<<std::endl;
std::string name;
std::cout<<
return 0;
}
\ No newline at end of file
namespace mujstd = std;
int main(int argc, char *argv[])
{
std::cout << "Ahoj PPC" << std::endl;
A::foo();
B::foo();
mujstd::cout << " Vypis ale bez std" << mujstd::endl;
int a, b;
std::cout << "Zadej dve cisla:" << std::endl;
std::cin >> a >> b;
if(std::cin.good())
{
std::cout << "Zadal jsi: " << a << " a " << b << std::endl;
}
else
{
std::cout << "Chyba, zopakuj si datove typy" << std::endl;
std::cout << ((std::cin.rdstate() & std::ios_base::badbit) ? "B" : "b");
std::cout << ((std::cin.rdstate() & std::ios_base::failbit) ? "F" : "f");
std::cout << ((std::cin.rdstate() & std::ios_base::eofbit) ? "E" : "e");
std::cout << std::endl;
}
double pi = 3.14159;
std::cout << pi << std::endl;
std::cout << std::setprecision(3) << pi << std::endl;
std::cout << std::setw(10) << pi << std::endl;
std::cout << std::fixed << pi << std::endl;
std::cout << std::scientific << pi << std::endl;
//+ Nacitani retezce (string) probiha po slovech (ta jsou oddelena bilym znakem)
std::string name, line;
std::cout << "Zadej jmeno:" << std::endl;
std::cin >> name;
std::cout << "Zadal jsi: " << name << std::endl;
//+ Pro nacteni celeho radku lze pouzit std::getline(std::cin, name)
std::cout << "Zadej cele jmeno:" << std::endl;
std::getline(std::cin, line);
std::cout << "Zadal jsi: " << line << std::endl;
//+ Radek jde potom zpracovat dalsimi funkcemi
//+ Napriklad: line.find(), std::regex_match,...
return 0;
}
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment