The Number - 2011 STD Test 1-9 was released on: USA: 24 June 2012
#include // std::ostream, std::cout, std::endl#include // std::string#include // std::vector#include // std::sortclass name{friend std::ostream& operator
#include<iostream> #include<vector>#include<string> int main() { std::vector<std::string> names; for (int loop=0; loop!=10;) { std::cout << ++loop << " enter a name: "; std::string name; std::cin >> name; names.push_back (name); } names.sort(); std::cout << "Sorted names:" << std::endl; for (auto name : names) std::cout << name << std::endl; }
form_title= STD Clinics form_header= Ensure your safety with a visit to a STD clinic. Do you have health insurance?*= () Yes () No Are you sexually active?*= () Yes () No When was your last test?*= _ [50]
#include<iostream> #include<vector> #include<string> int main() { std::vector<std::string> names; for (int loop=0; loop!=10;) { std::cout << ++loop << " enter a name: "; std::string name; std::cin >> name; names.push_back (name); } }
form_title=Visit an STD Clinic form_header=An STD clinic can test for a variety of diseases. What are the symptoms you are experiencing?=_ How long have you had the symptoms?=_ Are you currently sexually active?= () Yes () No
depending on what what kind of test std go to you doctor
No,You Can not............
int main() { std::string first, last; std::cout << "Enter your first name: "; std::cin >> first; std::cout << "Enter your last name: "; std::cin >> last; }
#include<string> #include<iostream> std::ostream& alternate (std::ostream& os, const std::string& str) { for (size_t index=0; index<str.size(); index+=2) os << str[index]; return os; } int main (void) { std::string test {"The quick brown fox jumps over the lazy dog"}; alternate (std::cout, test); std::cout << std::endl; } Output: Teqikbonfxjmsoe h aydg
#include<iostream> #include<fstream> #include<string> std::string get_filename () { std::string filename {}; while (filename.empty()) { std::cout<<"Enter a file name: "; std::cin.clear(); std::getline (std::cin, filename); // strip quotes from the file name size_t b {filename.find ('"')}; size_t e {filename.rfind ('"')}; if (b!=filename.npos && e!=filename.npos) filename = filename.substr (++b, e-b); // test the file name is valid std::ifstream file {filename}; if (!file) { std::cout << "Invalid filename\n"; filename=""; } } return filename; } int main (void) { std::ifstream file {get_filename()}; size_t digits {0}; size_t letters {0}; size_t others {0}; while (!file.eof()) { char c = file.get(); if (c>='0' && c<='9') ++digits; else if ((c>='a' && c<='z') (c>='A' && c<='Z')) ++letters; else ++others; } std::cout<<"Digits: "<<digits<<std::endl; std::cout<<"Letters: "<<letters<<std::endl; std::cout<<"Others: "<<others<<std::endl; }
#include<iostream> #include<fstream> #include<string> struct record { std::string title; std::string artist; }; std::ostream& operator << (std::ostream& os, const record& r) { return os << r.title << '\n' << r.artist; } std::istream& operator >> (std::istream& is, record& r) { getline (is, r.title); getline (is, r.artist); return is; } int main() { std::ofstream ofs; ofs.open ("test", std::ios::binary); record out1 {"Master of Puppets", "Metallica"}; record out2 {"Permanent Waves", "Rush"}; ofs << out1 << std::endl; ofs << out2 << std::endl; ofs.close(); std::ifstream ifs; ifs.open ("test", std::ios::binary); record in1, in2; ifs >> in1 >> in2; ifs.close(); std::cout << "Record 1:\n" << in1 << std::endl; std::cout << "Record 2:\n" << in2 << std::endl; }