- •Привет, мир
- •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 _tmain(int argc, _tchar* argv[])
{
char S [255];
setlocale(LC_CTYPE,"Russian");
printf("Введите строку:\n");
gets(S);
DubleEngLeters(S);
return 0;
}
Задача 18
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#define N_CARS 15
#define MAX_LENGTH 30
#define REVERSE_ORDER true
#define STRAIGHT_ORDER false
char Cars[N_CARS][MAX_LENGTH] = {
"Хаммер", "Ламборджини", "Лексус",
"Вольво", "Фольскваген", "Опель",
"БМВ", "Мазда", "Тойота",
"Майбах", "Шкода","Ока",
"Феррари", "Хонда", "Ауди"
};
void printCars();
void sortCars(bool order);
void printMenu();
int getChoice();
Int main() {
setlocale(LC_ALL,"Russian");
while (true) {
printMenu();
switch(getChoice()) {
case 1 :
sortCars(STRAIGHT_ORDER);
printCars();
break;
case 2 :
sortCars(REVERSE_ORDER);
printCars();
break;
case 0 :
exit(EXIT_SUCCESS);
default :
exit(EXIT_FAILURE);
}
system("pause");
}
return 0;
}
void printCars() {
for (int i=0; i<N_CARS; i++) {
puts(Cars[i]);
}
}
void sortCars(bool order) {
for (int i=0; i<N_CARS-1; i++) {
int min=i;
for (int j=i+1; j<N_CARS; j++) {
if (order ^
strcmp(Cars[min], Cars[j])>0) {
min=j;
}
}
char temp[MAX_LENGTH];
strcpy(temp, Cars[min]);
strcpy(Cars[min], Cars[i]);
strcpy(Cars[i], temp);
}
}
void printMenu() {
system("cls");
printf("---МЕНЮ---\n");
printf("1-Прямой порядок\n");
printf("2-Обратный порядок\n");
printf("0-Выход\n");
printf("Ваш выбор - ");
}
int getChoice() {
int choice;
scanf("%d", &choice);
if (choice<0 || choice>2) {
printf("Нет такого пункта\n");
printf("Выберите еще раз - ");
return getChoice();
}
return choice;
}
Задача 23
#include "stdafx.h"
#include <string.h>
#include <stdlib.h>
#include <locale.h>
bool isNumber(char Symbol);
int SumOfNumbersInString(char A []);
Int _tmain(int argc, _tchar* argv[])
{
char A [255];
setlocale(LC_CTYPE,"Russian");
printf("Введите строку: \n");
gets(A);
printf("%d", SumOfNumbersInString(A));
scanf("");
return 0;
}
int SumOfNumbersInString(char A [])
{
int sum = 0;
for (int i = 0; i < strlen(A); i++)
{
if (isNumber(A[i]))
{
char s_num[2];
s_num[0] = A[i];
s_num[1] = '\0';
sum += atoi(s_num);
}
}
return sum;
}
bool isNumber(char Symbol)
{
return Symbol >= '0' && Symbol <= '9';
}
лаба №9 Задача 2
#include "stdafx.h"
#include <stdio.h>
#include <windows.h>
#include <locale.h>
void main() {
int N;
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
printf("Введите число N:\n");
scanf("%d", &N);
FILE*myFile = fopen("fibonachchi", "w");
int fib_0=0;
int fib_1=1;
for (int i=0; i<N; i++)
{
int fib_2 = fib_0+fib_1;
fprintf(myFile, "%d ", fib_2);
fib_0=fib_1;
fib_1=fib_2;
}
fclose(myFile);
}
Задача 6
#include "stdafx.h"
#include <stdio.h>
#include <locale.h>
#include <string.h>
bool isEngVowel(char symbol)
{
char engVows[] = "aeiouyAEIOUY";
for (int i=0; i<strlen(engVows); i++)
{
if (symbol==engVows[i])
{
return true;
}
}
return false;
}
int NumberEng(FILE* in)
{
int num=0;
while (feof(in) == false)
{
char symbol = fgetc(in);
if (isEngVowel(symbol))
{
num++;
}
}
return num;
}
void main()
{
setlocale(LC_CTYPE,"Russian");
FILE* f = fopen("text.txt", "r");
printf("%d",NumberEng(f));
fclose(f);
}
Задача 14
#include "stdafx.h"
#include <stdio.h>
#include <locale.h>