initial
This commit is contained in:
commit
2802401eee
79 changed files with 2650 additions and 0 deletions
34
1sem/adaptation courses/11/33.cpp
Normal file
34
1sem/adaptation courses/11/33.cpp
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
// ac_11_33.cpp
|
||||
// Горбацевич Андрей
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void read_string(istream &reader, string &where, char delimiter) {
|
||||
char c;
|
||||
while ((c = reader.get()) != delimiter && reader.good()) {
|
||||
where += c;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
vector<string> strs;
|
||||
ifstream inf("in.txt");
|
||||
if (!inf.is_open())
|
||||
{
|
||||
cerr << "Unable to open file" << endl;
|
||||
return 1;
|
||||
}
|
||||
while (!inf.eof()) {
|
||||
string s;
|
||||
read_string(inf, s, '\n');
|
||||
strs.push_back(s);
|
||||
}
|
||||
for (auto it = strs.end(); it-- != strs.begin();) {
|
||||
cout << *it << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
52
1sem/adaptation courses/11/34.cpp
Normal file
52
1sem/adaptation courses/11/34.cpp
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
// ac_11_34.cpp
|
||||
// Горбацевич Андрей
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int count_words(const string &str) {
|
||||
bool inSpaces = true;
|
||||
int numWords = 0;
|
||||
auto it = begin(str);
|
||||
while (*it != '\0')
|
||||
{
|
||||
if (isspace(*it))
|
||||
{
|
||||
inSpaces = true;
|
||||
}
|
||||
else if (inSpaces)
|
||||
{
|
||||
numWords++;
|
||||
inSpaces = false;
|
||||
}
|
||||
|
||||
++it;
|
||||
}
|
||||
return numWords;
|
||||
}
|
||||
|
||||
void read_string(istream &reader, string &where, char delimiter) {
|
||||
char c;
|
||||
while ((c = reader.get()) != delimiter && reader.good()) {
|
||||
where += c;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
ifstream inf("in.txt");
|
||||
if (!inf.is_open())
|
||||
{
|
||||
cerr << "Unable to open file" << endl;
|
||||
return 1;
|
||||
}
|
||||
while (!inf.eof()) {
|
||||
string s;
|
||||
read_string(inf, s, '\n');
|
||||
cout << count_words(s) << " words: " << s << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
37
1sem/adaptation courses/11/35.cpp
Normal file
37
1sem/adaptation courses/11/35.cpp
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
// ac_11_35.cpp
|
||||
// Горбацевич Андрей
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#define MAX_STRING 5000
|
||||
|
||||
using namespace std;
|
||||
|
||||
string get_short_name(const string &full_name) {
|
||||
char s[MAX_STRING], n[MAX_STRING], f[MAX_STRING], out[MAX_STRING];
|
||||
sscanf(full_name.c_str(), "%s %s %s", s, n, f);
|
||||
sprintf(out, "%s %c.%c.", s, n[0], f[0]);
|
||||
return string(out);
|
||||
}
|
||||
|
||||
void read_string(istream &reader, string &where, char delimiter) {
|
||||
char c;
|
||||
while ((c = reader.get()) != delimiter && reader.good()) {
|
||||
where += c;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
ifstream inf("in.txt");
|
||||
if (!inf.is_open())
|
||||
{
|
||||
cerr << "Unable to open file" << endl;
|
||||
return 1;
|
||||
}
|
||||
while (!inf.eof()) {
|
||||
string s;
|
||||
read_string(inf, s, '\n');
|
||||
cout << get_short_name(s) << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue