- •Привет, мир
- •2. Перевод радиан в градусы
- •6. Площадь и периметр трапеции
- •Int _tmain(int argc, _tchar* argv[])
- •14. Типы данных с
- •Int _tmain(int argc, _tchar* argv[])
- •18.Диаметр, длина и площадь окружности
- •Int _tmain(int argc, _tchar* argv[])
- •23. Приветствие
- •Int _tmain(int argc, _tchar* argv[])
- •2. Значения битов
- •Int _tmain(int argc, _tchar* argv[])
- •6. Средний балл
- •Int main() {
- •14. Расстояние Хемминга
- •Int main() {
- •18. Среднее геометрическое
- •Int main() {
- •23. Площадь сектора
- •Int _tmain(int argc, _tchar* argv[])
- •2. Спортсмены
- •Int main()
- •6. Скидка на обучение
- •Int _tmain(int argc, _tchar* argv[])
- •Int _tmain(int argc, _tchar* argv[])
- •18. Нечётные числа
- •Int _tmain(int argc, _tchar* argv[])
- •23. Квадратное уравнение
- •Int _tmain(int argc, _tchar* argv[])
- •Int main() {
- •Int main() {
- •Int main() {
- •Int main() {
- •Int _tmain(int argc, _tchar* argv[])
- •Int _tmain(int argc, _tchar* argv[])
- •Int _tmain(int argc, _tchar* argv[])
- •Int _tmain(int argc, _tchar* argv[])
- •Int main() {
- •Int _tmain(int argc, _tchar* argv[])
- •Int _tmain(int argc, _tchar* argv[])
- •Int main()
- •Int main()
- •Int _tmain(int argc, _tchar* argv[])
- •Int main() {
- •Int _tmain(int argc, _tchar* argv[])
- •Int main()
- •Int main() {
- •Int main() {
- •Int main() {
- •Int main() {
- •Int main() {
Int main()
{
int N=0;
setlocale(0,"Russian");
FILE* f = fopen("14_1.txt", "r");
FILE* f2 = fopen("14_2.txt", "w");
while (!feof(f))
{
N++;
char symbol = fgetc(f);
if(N % 3 != 0)
{
fputc(symbol,f2);
}
}
fclose(f);
fclose(f2);
}
Задача 18
#include "stdafx.h"
#include <stdio.h>
#include <locale.h>
void main() {
setlocale(LC_CTYPE,"Russian");
FILE* myFile = fopen("myFile.txt", "r");
fseek(myFile, 0, SEEK_END);
int size = ftell(myFile);
for (int i=0; i<size/2; i++)
{
fseek(myFile, -(i+1), SEEK_END);
putchar(fgetc(myFile));
fseek(myFile, i, SEEK_SET);
putchar(fgetc(myFile));
}
fclose(myFile);
}
Задача 23
#include "stdafx.h"
#include <stdio.h>
#include <locale.h>
#include <string.h>
bool isRusLetter(char symbol)
{
char rusLetter[] = "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЪЧШЩЬЫЭЮЯ";
for (int i=0; i<strlen(rusLetter); i++)
{
if (symbol==rusLetter[i])
{
return true;
}
}
return false;
}
float NumberRus(FILE* in)
{
int num = 0;
float result = 0;
while (!feof(in))
{
char symbol = fgetc(in);
if (isRusLetter(symbol))
{
num++;
}
int size = ftell(in);
result = (float)num/size;
}
return result;
}
void main()
{
setlocale(0,"Russian");
FILE* f = fopen("chastota.txt","r");
printf("Частота %0.2f\n",NumberRus(f));
fclose(f);
}
Лаба № 10 //Задача 2
#include "stdafx.h"
#include <iostream>
#include <stdlib.h>
#include <locale.h>
struct Vector { float x; float y; float z; };
float getDifferenceVector(Vector v1, Vector v2) {
return sqrt(((v1.x-v2.x)*(v1.x-v2.x)) + ((v1.y-v2.y)*(v1.y-v2.y)) + ((v1.z-v2.z)*(v1.z-v2.z)));
}
Int main() {
setlocale(LC_CTYPE,"Russian");
Vector vect1 = {15.6, 45.7, 2.9};
Vector vect2 = {17.2, 35.6, 17.7};
printf("Вектор равен: %g\n", getDifferenceVector(vect1, vect2));
return 0;
}
//Задача 6
#include "stdafx.h"
#include <iostream>
#include <stdlib.h>
#include <locale.h>
#include <math.h>
struct Vector { float x; float y; float z; };
float getUgolVector(Vector v1, Vector v2) {
return ((float) acos((v1.x*v2.x+v1.y*v2.y+v1.z*v2.z)/
(float) sqrt((v1.x*v1.x+v1.y*v1.y+v1.z*v1.z)*
(v2.x*v2.x+v2.y*v2.y+v2.z*v2.z))))*180/3.14159265;
}
Int main() {
setlocale(LC_CTYPE,"Russian");
Vector vect1 = {0.0, 0.0, 3.0};
Vector vect2 = {0.0, 0.0, -3.0};
printf("Угол между векторами: %g\n", getDifferenceVector(vect1, vect2));
return 0;
}
//Задача 18
#include "stdafx.h"
#include <iostream>
using namespace std;
struct Film {
char name[100];
char director[100];
char genre[100];
int duration;
int budget;
};
Film films[10] = {
{"Спеши любить", "Ник Кассаветис", "Драма", 120 , 80000000},
{"Трон", "Майкл Бэй", "Фантастика", 144, 170000000 },
{"Кошмары на улице Вязов", "Дэннис Илиадис","Ужасы",123,17000000},
{"Приют", "Жауме Серра","Ужасы" ,128, 14000000},
{"Три метра над уровнем неба", "Кэтрин Хардвик", "Драма", 140, 2500000},
{"Очень страшное кино","Том Вон","Комедия",135,1250000},
{"Эффект бабочки","Эрик Бресс","Фантастика",123,1500000},
{"Геймер","Джефф Уадлоу","Боевик",127,16900000},
{"Звёздная пыль","Дэвид Йэтс","Фэнтези",135,1380000},
{"Мы купили зоопарк","Алехандро Агрести","Драма",133,13500000},
}