1)
#include <stdafx. h>
#include <iostream>
#include <conio. h>
using namespace::std;
// F_students. cpp:
//
class student {
char name[40];
int oc;
public:
void in()
{
cin » name » oc;
cout « endl;
}
void out()
{
cout « name « " " « oc;
}
};
int main() {
student std[5];
for (int i=0; i<5; i++)
{
std[i].in();
}
for (int i=0; i<5; i++)
{
std[i].out();
cout » endl;
}
_getch();
return 0;
}
Второй пример:
2)#include "stdafx. h"
#include <iostream>
#include <conio. h>
using namespace std;
class cRabbit{
public:
int v;
};
class cWolf {
public:
int v;
int t;
int rasstoyanie(int v1) {
return t*v1/(v-v1);
}
};
int _tmain(int argc, _TCHAR* argv[])
{
setlocale(LC_CTYPE, "Russian");
cWolf wolk;
cRabbit rabb;
cout « "Введите скорость зайца:"; cin » rabb. v;
cout « "Введите скорость волка:"; cin » wolk. v;
cout « "Введите время отставания:"; cin » wolk. t;
cout « wolk. rasstoyanie(rabb. v) « endl;
return 0;
2)Вторая задача включает в себя вывод информации в файл.
#include "stdafx. h"
#include <iostream>
#include <fstream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
ifstream fin("C:\Documents and Settings\u0310938\Рабочий стол\\Stih. txt")
char asd [4][30];
int i = 0;
while (fin. good()){
fin. getline(asd[i],30);
i++;
}
fin. close();
ofstream fout ( C:\Documents and Settings\u0310938\Рабочий стол\\Stih. txt")
for (int i = 0; i < 4; i = i + 2) {
fout « asd[i] « endl;
}
fout. close();
return 0;
}


