- •Мгул, пм-21, 4 семестр, 2012 год
- •Контрольная работа №2
- •Class Command (Calculator) (лаб. Раб. №3)
- •Задание * (лаб. Раб. №4)
- •Дать описание классов, созданных в файлах: Array.H, Array.Cpp
- •12.1. Исходный код файла Array.H (лаб. Раб. №5)
- •12.2. Исходный код файла Array.Cpp (лаб. Раб. №6)
- •Выполнить задание (лаб. Раб. №7)
- •Дать описание классов проекта Kolobok («Колобок») (лаб. Раб. №8)
- •В проект Kolobok добавить персонаж RedCup («Красная шапочка») (лаб. Раб. №9)
Мгул, пм-21, 4 семестр, 2012 год
Контрольные и лабораторные работы
Для получения допуска к экзамену необходимо получить зачёт по следующим темам:
Контрольная работа № 1 (проверка остаточных знаний)
// 1. Исправить ошибки в функциях, при условии, что все эти функции должны
// возвращать длину строки, поданной в функцию в качестве аргумента.
// 2. Указать единственную функцию без ошибок.
int f1(char c[])
{
int i;
for (; c[i]; i++)
;
return i;
}
int f2(char *c)
{
char *cc = c;
while (*cc++);
return cc - c;
}
int f3(char s[])
{
int i = 0;
foreach (char c in s)
if (c == 0)
return i;
else
i++;
}
int f4(char *c)
{
int i == 0;
while (*c++)
i++;
return i;
}
int f5(char *c)
{
char *cc = c;
while (*cc)
cc++;
return c + cc;
}
int f6(char c[])
{
int i = -1;
repeat
{
i++;
}
until (c[i] == 0);
return i;
}
int f7(char []c)
{
int i = 0;
l:
if (c[i] == 0)
return i;
i++;
goto l;
}
int f8(char *c)
{
char *cc = c;
while ((int)cc & 3)
if (!*cc++)
return cc - c - 1;
int *ccc = (int *)cc;
int i;
do
{
i = *ccc++;
i ^= ~(i + 0x7efefeff);
}
while (!(i & 0x81010100));
cc = (char *)(ccc - 1);
if (!(*cc & 0xff))
return cc - c;
if (!(*++cc & 0xff))
return cc - c;
if (!(*++cc & 0xff))
return cc - c;
return cc - c + 1;
}
Фамилия __________________
Класс, свойства класса: инкапсуляция, наследование, полиморфизм
Конструктор копирования, оператор присваивания
Дружественные функции
Статические члены класса
Наследование классов, производный класс
class Complex (лаб. раб. №1)
// Задание
// 1. Разобраться в программе
// 2. Дописать методы с пустыми телами
// 2. Дописать функцию main(...) так, чтобы при работе программы были использованы все методы класса Complex
#include <iostream>
#include <conio.h>
#include <math.h>
using namespace std;
class Complex {
double real;
double im;
public:
Complex(Complex &c)
{
real = c.real;
im = c.im;
}
Complex(double real = 0.0, double im = 0.0)
{
this->real = real;
this->im = im;
}
Complex operator +(Complex &c1)
{
return Complex(real + c1.real, im + c1.im);
}
Complex operator -(Complex &c1)
{
}
Complex operator *(Complex &c1)
{
}
Complex operator /(Complex &c1)
{
}
Complex &operator +=(Complex &c1)
{
}
Complex &operator -=(Complex &c1)
{
}
Complex &operator *=(Complex &c1)
{
}
Complex &operator /=(Complex &c1)
{
}
Complex operator =(Complex c)
{
}
Complex operator +(double a) { }
Complex operator -(double a) { }
Complex &operator +=(double a) { }
Complex &operator -=(double a) { }
Complex operator *(double a) { }
Complex operator /(double a) { }
Complex &operator *=(double a) { }
Complex &operator /=(double a) { }
Complex operator =(double a) { }
friend ostream &operator <<(ostream &out, Complex c1);
void print();
Complex abs(Complex &c1);
Complex sopr(Complex &c1);
};
ostream &operator <<(ostream &out, Complex c1)
{
return out << '<' << c1.real << ',' << c1.im << '>';
}
void Complex::print()
{
printf("<%g, %g>", real, im);
}
Complex Complex::abs(Complex &c1)
{
}
Complex Complex::sopr(Complex &c1)
{
}
int main()
{
Complex c1(1.0, 2.0);
Complex c2(3.0, -1.0);
Complex c3 = c1 + c2;
…
}