Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
sem4-.doc
Скачиваний:
1
Добавлен:
13.08.2019
Размер:
92.67 Кб
Скачать

Мгул, пм-21, 4 семестр, 2012 год

Контрольные и лабораторные работы

Для получения допуска к экзамену необходимо получить зачёт по следующим темам:

  1. Контрольная работа № 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;

}

Фамилия __________________

  1. Класс, свойства класса: инкапсуляция, наследование, полиморфизм

  2. Конструктор копирования, оператор присваивания

  3. Дружественные функции

  4. Статические члены класса

  5. Наследование классов, производный класс

  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;

}

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]