Yes, STD's are everywhere.
above vi std players are used volleyball serve
#include<iostream> int main() { std::cout << "sin(1) = " << std::sin(1.0) << std::endl; std::cout << "cos(1) = " << std::cos(1.0) << std::endl; std::cout << "tan(1) = " << std::tan(1.0) << std::endl; std::cout << "asin(1) = " << std::asin(1.0) << std::endl; std::cout << "acos(1) = " << std::acos(1.0) << std::endl; std::cout << "atan(1) = " << std::atan(1.0) << std::endl; } Output: sin(1) = 0.841471 cos(1) = 0.540302 tan(1) = 1.55741 asin(1) = 1.5708 acos(1) = 0 atan(1) = 0.785398
#include<iostream> #include<vector> #include<string> std::vector<std::string> parse (const std::string& s, const char delim) { std::vector<std::string> result {}; auto start = 0U; auto end = s.find (delim); while (end != s.npos) { result.push_back (s.substr(start, end - start)); start = ++end; end = s.find (delim, start); } result.push_back (s.substr (start, s.npos - start)); return result; } std::vector<std::string> parse (const std::string& s, const std::string& delim) { std::vector<std::string> result {}; auto start = 0U; auto end = s.find (delim); while (end != s.npos) { result.push_back (s.substr(start, end - start)); start = end + delim.length(); end = s.find (delim, start); } result.push_back (s.substr (start, s.npos - start)); return result; } int main() { std::string str1 = "This is a string that will be parsed by a single-space delimiter."; std::string str2 = "This==is==a==string==that==will==be==parsed==by==equal==operator."; std::string str3 = "This string has no delimiter."; std::cout << str1 << std::endl; std::vector<std::string> v1 = parse (str1, ' '); for (auto i : v1 ) std::cout << i << std::endl; std::cout << std::endl; std::cout << str2 << std::endl; std::vector<std::string> v2 = parse (str2, "=="); for (auto i : v2 ) std::cout << i << std::endl; std::cout << std::endl; std::cout << str3 << std::endl; std::vector<std::string> v3 = parse (str3, '\\'); for (auto i : v3 ) std::cout << i << std::endl; std::cout << std::endl; }
The following example demonstrates all 4 loop structures in C++. #include<iostream> int main() { int i; std::cout<<"For loop...\n"<<std::endl; for(i=0; i<10; ++i) std::cout<<i; std::cout<<'\n'<<std::endl; std::cout<<"While loop...\n"<<std::endl; i=0; while(i<10) std::cout<<i++; std::cout<<'\n'<<std::endl; std::cout<<"Do-while loop...\n"<<std::endl; i=0; do { std::cout<<i; }while( ++i<10 ); std::cout<<'\n'<<std::endl; std::cout<<"Goto loop...\n"<<std::endl; i=0; again: std::cout<<i; if(++i<10) goto again; std::cout<<'\n'<<std::endl; } Output: For loop... 0123456789 While loop... 0123456789 Do-while loop... 0123456789 Goto loop... 0123456789
Mumps is not a STD.
Haemophilus is not a STD.
#include<iostream> #include<array> #include<string> #include<random> #include<ctime> using player_t = std::array<unsigned, 2>; using pair_t = std::pair<unsigned, unsigned>; using snake_t = std::array<pair_t, 10>; using ladder_t = std::array<std::pair<unsigned, unsigned>, 9>; const std::string player (const bool human) { return std::string {human ? "You" : "I"}; } int main() { std::default_random_engine generator ((unsigned) time (0)); std::uniform_int_distribution<unsigned> distribution (1, 6); player_t players = {0,0}; const snake_t snakes = {pair_t {98,78}, {95,75}, {93,73}, {87,24}, {64,60}, {62,19}, {56,53}, {49,11}, {47,26}, {16,6}}; const ladder_t ladders = {pair_t {1,38}, {4,14}, {9,31}, {21,42}, {28,84}, {36,44}, {51,67}, {71,91}, {80,100}}; std::cout << "Snakes and Ladders\n"; std::cout << "==================\n\n"; std::cout << "First to land exactly on square 100 wins.\n"; bool human = (distribution (generator) % 2)==0 ? true : false; std::cout << player (human) << " will go first.\n\n"; for (;;human=!human) { std::cout << (human ? "Your" : "My") << " turn:\n"; unsigned dice = distribution (generator); std::cout << '\t' << player (human) << " rolled a " << dice << ".\n"; unsigned& pos = players [human?0:1]; if (pos+dice>100) { std::cout << '\t' << player (human) << " cannot move.\n"; goto turn_over; } pos+=dice; std::cout << '\t' << player (human) << " landed on square " << pos; for (auto snake : snakes) { if (snake.first==pos) { pos = snake.second; std::cout << " with a snake; return to square " << pos; goto turn_over; } } for (auto ladder : ladders) { if (ladder.first==pos) { pos = ladder.second; std::cout << " with a ladder; climb to square " << pos; goto turn_over; } } turn_over: std::cout << ".\n\n"; if (pos==100) { std::cout << "You " << (human ? "won" : "lost") << "!\n"; break; } } }
#include<iostream> #include<array> #include<string> #include<random> #include<ctime> using player_t = std::array<unsigned, 2>; using pair_t = std::pair<unsigned, unsigned>; using snake_t = std::array<pair_t, 10>; using ladder_t = std::array<std::pair<unsigned, unsigned>, 9>; const std::string player (const bool human) { return std::string {human ? "You" : "I"}; } int main() { std::default_random_engine generator ((unsigned) time (0)); std::uniform_int_distribution<unsigned> distribution (1, 6); player_t players = {0,0}; const snake_t snakes = {pair_t {98,78}, {95,75}, {93,73}, {87,24}, {64,60}, {62,19}, {56,53}, {49,11}, {47,26}, {16,6}}; const ladder_t ladders = {pair_t {1,38}, {4,14}, {9,31}, {21,42}, {28,84}, {36,44}, {51,67}, {71,91}, {80,100}}; std::cout << "Snakes and Ladders\n"; std::cout << "==================\n\n"; std::cout << "First to land exactly on square 100 wins.\n"; bool human = (distribution (generator) % 2)==0 ? true : false; std::cout << player (human) << " will go first.\n\n"; for (;;human=!human) { std::cout << (human ? "Your" : "My") << " turn:\n"; unsigned dice = distribution (generator); std::cout << '\t' << player (human) << " rolled a " << dice << ".\n"; unsigned& pos = players [human?0:1]; if (pos+dice>100) { std::cout << '\t' << player (human) << " cannot move"; goto next_player; } pos+=dice; std::cout << '\t' << player (human) << " landed on square " << pos; for (auto snake : snakes) { if (snake.first==pos) { pos = snake.second; std::cout << " with a snake; return to square " << pos; goto next_player; } } for (auto ladder : ladders) { if (ladder.first==pos) { pos = ladder.second; std::cout << " with a ladder; climb to square " << pos; goto next_player; } } next_player: std::cout << ".\n\n"; if (pos==100) { std::cout << player (human) << " won!\n"; break; } } }
int main() { std::string first, last; std::cout << "Enter your first name: "; std::cin >> first; std::cout << "Enter your last name: "; std::cin >> last; }
std::cout << std::bitset<CHAR_BIT>( 876 ) << std::endl;
#include<iostream> int main() { int num1, num2; std::cout << "C++ addition program" << std::endl; std::cout << "Enter a number: "; std::cin >> num1; std::cout << "Enter another number: "; std::cin >> num2; std::cout << "The sum is " << num1 + num2 << std::endl; }