Академический Документы
Профессиональный Документы
Культура Документы
123
123
h>
#include <iostream>
#include <windows.h>
using namespace std;
void practice0()
{
// var_6.cpp :
#include <iostream>
#include <windows.h>
#include <string>
struct Date {
unsigned short day;
unsigned short month;
unsigned short year;
};
struct Record
{
char surName[17];
char commandCode;
double score;
unsigned short place;
struct Date date;
};
int w = s.length();
int delta = (wLine - w) / 2;
cout << left;
cout.width(delta); cout << " ";
cout << s;
cout.width(delta + 1); cout << " ";
void printDate(unsigned short day, unsigned short month, unsigned short year, int
wLine) {
int w = 10;
int delta = (wLine - w) / 2 - 1;
cout << left;
cout.width(delta); cout << " ";
if (day > 9) {
cout << day;
}
else {
cout << "0" << day;
}
cout << ".";
if (month > 9) {
cout << month;
}
else {
cout << "0" << month;
}
cout << ".";
cout << year;
cout.width(delta); cout << " ";
}
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
Draw(records);
}
}
void practice1()
{
#include <iostream>
struct Date {
int day;
int month;
int year;
};
struct Record {
char username[25];
char code;
double points;
int place_in_rating;
struct Date date;
};
void practice2()
{
void practice3()
{
void practice4()
{
#include <iostream>
#include <fstream>
#include <windows.h>
struct Date {
int day;
int month;
int year;
};
struct Record {
char username[25];
char code;
double points;
int place_in_rating;
struct Date date;
};
vo
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
ofstream fileRecord("Алешкин.txt");
for (int i = 0; i < 3; i++) {
fileRecord << line[i].username << " ";
fileRecord << line[i].code << " ";
fileRecord << line[i].points << " ";
fileRecord << line[i].place_in_rating << " ";
fileRecord << line[i].date.day << " ";
fileRecord << line[i].date.month << " ";
fileRecord << line[i].date.year << " \n";
}
fileRecord.close();
ifstream textFstream;
textFstream.open("Алешкин.txt", ios_base::in);
struct Record readLine[3];
for (int i = 0; i < 3; i++) {
textFstream >> readLine[i].username;
textFstream >> readLine[i].code;
textFstream >> readLine[i].points;
textFstream >> readLine[i].place_in_rating;
textFstream >> readLine[i].date.day;
textFstream >> readLine[i].date.month;
textFstream >> readLine[i].date.year;
}
textFstream.close();
Draw(readLine, 3);
ofstream filenewrecord;
filenewrecord.open("Алешкин.txt", ios::app);
struct Record new_record;
cout << "Введите фамилию участника: ";
cin >> new_record.username;
cout << "Введите код команды: ";
cin >> new_record.code;
cout << "Введите количество баллов: ";
cin >> new_record.points;
cout << "Введите место в итоге: ";
cin >> new_record.place_in_rating;
cout << "Введите дату выступления: ";
cin >> new_record.date.day >> new_record.date.month >> new_record.date.year;
filenewrecord << new_record.username << " ";
filenewrecord << new_record.code << " ";
filenewrecord << new_record.points << " ";
filenewrecord << new_record.place_in_rating << " ";
filenewrecord << new_record.date.day << " " << new_record.date.month << " " <<
new_record.date.year << "\n";
filenewrecord.close();
ifstream fileswaplines;
fileswaplines.open("Алешкин.txt", ios_base::in);
struct Record readLinenew[4];
for (int i = 0; i < 4; i++) {
swap(readLinenew[2].username, readLinenew[3].username);
swap(readLinenew[2].code, readLinenew[3].code);
fileswaplines.close();
ofstream fileswapliness;
fileswapliness.open("Алешкин.txt", ios_base::out);
for (int i = 0; i < 4; i++) {
fileswapliness << readLinenew[i].username << " ";
fileswapliness << readLinenew[i].code << " ";
fileswapliness << readLinenew[i].points << " ";
fileswapliness << readLinenew[i].place_in_rating << " ";
fileswapliness << readLinenew[i].date.day << " " <<
readLinenew[i].date.month << " " << readLinenew[i].date.year << "\n";
}
fileswapliness.close();
Draw(readLinenew, 4);
}
void practice5()
{
void practice6()
{
#include <iostream>
class A {
public:
void f() { cout << "A"; }
A() { cout << "constructor A\n"; }
};
};
int main()
{
F object; object.f();
return 0;
}
int main(void)
{
UINT ConsoleCP=GetConsoleCP(),ConsoleOutputCP=GetConsoleOutputCP();
SetConsoleCP(CP_WIN1251),SetConsoleOutputCP(CP_WIN1251);
bool state=true;
while(state)
{
const int q=7;
for(auto i=0;i<q;++i)cout<<i+1<<" Практика "<<i<<'\n';
cout<<"0. Выход";
fflush(stdin);
string buff={};
cout<<'\n'<<"Введите команду: ";
cin>>buff;
if(!validate(buff))
{
cout<<"Некорректная команда"<<'\n';
system("pause&&cls");
continue;
}
switch(stoui(buff))
{
case 0:
state=false;
continue;
case 1:
practice0();
break;
case 2:
practice1();
break;
case 3:
practice2();
break;
case 4:
practice3();
break;
case 5:
practice4();
break;
case 6:
practice5();
break;
case 7:
practice6();
break;
default:
cout<<"Некорректная команда"<<'\n';
system("pause&&cls");
continue;
//etc
}
system("pause&&cls");
}
SetConsoleCP(ConsoleCP),SetConsoleOutputCP(ConsoleOutputCP);
}