#include
#include
#include
#include
using namespace std;
struct student {
char fio[80];
short age;
student(const char* fio, short age) : age(age) {
strncpy_s(this->fio, fio, sizeof(this -> fio));
}
};
inline ostream& operator <<(ostream& out, const student& obj)
{
return out << obj.fio << "\t: " << obj.age;
}
struct trimatrix : vector< vector> {
trimatrix(int n) {
while (n > 0) {
vector row(n);
for (int i = 0; i < n; i++)
row[i] = n - i;
push_back(row);
n--;
}
}
};
inline ostream& operator << (ostream& out, const trimatrix& obj) {
for (int i = 0; i < obj.size(); i++) {
for (int j = 0; j < obj[i].size(); j++)
cout << obj[i][j] << " ";
cout << endl;
}
return out;
}
int main(int argc, char ** argv) {
setlocale(LC_ALL, "rus");
vector group;
group.push_back(student("Boynazarov I.M.", 18));
group.push_back(student("Djumayozov U.Z.", 21));
group.push_back(student("Bobonazarov A.A.", 19));
for (int i = 0; i < group.size(); i++)
cout << group[i] << endl;
cout << trimatrix(4);
int k, n;
vector a(n = rand() + 1, true);
a[0] = a[1] = false;
for (k = 2; k < n; k++)
for (vector :: iterator j = a.begin() + k + k; j *j = false;
const int line = 10;
k = 0;
for (vector :: iterator j =a.begin(); j < a.end(); j++)
if (*j) {
cout << j - a.begin() << "\t";
if (0 == ++k% line)
cout<< endl;
}
if (k % line != 0)
cout << endl;
system("pause");
return 0;
}
|
1. Dasturdagi yangi tiplarni aniqlang.
________________________________
________________________________
________________________________
________________________________
|