Last active
August 29, 2015 13:57
-
-
Save SergXIIIth/9863325 to your computer and use it in GitHub Desktop.
Lab_2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <conio.h> | |
using namespace std; | |
int main() | |
{ | |
int period, interest; | |
float interest_in_period, amount, income; | |
// Ввод данных | |
printf("Доход\n"); // "\n" в конце означает перейти на новую строку | |
printf("Сумма, руб. -> "); | |
scanf("%f", &amount); | |
printf("Срок вклада, мес. -> "); | |
scanf("%i", &period); | |
// Рассчет | |
if (amount < 5000){ | |
interest = 10; | |
} | |
else { | |
interest = 13; | |
} | |
// расчет сколько процентов начилять за введенный период | |
interest_in_period = interest * period / 12; | |
// вычисляем процент дохода от введенной суммы | |
income = amount * interest_in_period / 100; | |
// Вывод результатов | |
printf("Срок вклада: %i мес.\n", period); | |
printf("Процент годовой: %i\n", interest); | |
printf("Доход: %.02f руб.\n", income); | |
printf("Cумма в конце срока вклада: %.02f руб.\n", amount + income ); | |
printf("\nНажмите любую клавишу для выхода"); | |
getch(); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <conio.h> | |
using namespace std; | |
int main() | |
{ | |
string input; | |
int day; | |
string day_names[7] = { | |
"Понедельник", | |
"Вторник", | |
"Среда", | |
"Четверг", | |
"Пятница", | |
"Суббота", | |
"Воскресенье" | |
}; | |
printf("Введине номер дня недели -> "); | |
scanf("%i", &day); | |
if ((1 <= day) && (day <= 7)){ | |
// Берем элемент из массива по индексу | |
// Индексом является введенный номер недели | |
// Вычитаем 1, т.к. в массиве индексы с нуля, а дни с единицы | |
printf("Вы ввели %s\n", day_names[day - 1]); | |
printf("\nНажмите любую клавишу для выхода"); | |
getch(); | |
return 0; | |
} | |
else { | |
printf("Ошибка. Допустимо вводить номер от 1 до 7"); | |
printf("\nНажмите любую клавишу для выхода"); | |
getch(); | |
return 1; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <conio.h> | |
using namespace std; | |
int main() | |
{ | |
printf("------------------------------------------\n"); | |
printf(" Таблица квадратов \n"); | |
printf("------------------------------------------\n"); | |
printf(" Число Квадрат\n"); | |
printf("------------------------------------------\n"); | |
printf(" 1 %i\n", 1 * 1); | |
printf("------------------------------------------\n"); | |
printf(" 2 %i\n", 2 * 2); | |
printf("------------------------------------------\n"); | |
printf(" 3 %i\n", 3 * 3); | |
printf("------------------------------------------\n"); | |
printf(" 4 %i\n", 4 * 4); | |
printf("------------------------------------------\n"); | |
printf(" 5 %i\n", 5 * 5); | |
printf("------------------------------------------\n"); | |
printf(" 6 %i\n", 6 * 6); | |
printf("------------------------------------------\n"); | |
printf(" 7 %i\n", 7 * 7); | |
printf("------------------------------------------\n"); | |
printf(" 8 %i\n", 8 * 8); | |
printf("------------------------------------------\n"); | |
printf(" 9 %i\n", 9 * 9); | |
printf("------------------------------------------\n"); | |
printf(" 10 %i\n", 10 * 10); | |
printf("------------------------------------------\n"); | |
printf("\nНажмите любую клавишу для выхода"); | |
getch(); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <conio.h> | |
using namespace std; | |
int main() | |
{ | |
int i = 1; | |
printf("------------------------------------------\n"); | |
printf(" Таблица квадратов \n"); | |
printf("------------------------------------------\n"); | |
printf(" Число Квадрат\n"); | |
printf("------------------------------------------\n"); | |
while (i <= 10) { | |
printf(" %i %i\n", i, i * i); | |
printf("------------------------------------------\n"); | |
i = i + 1; | |
} | |
printf("\nНажмите любую клавишу для выхода"); | |
getch(); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <conio.h> | |
using namespace std; | |
#define HB 5 | |
int main() | |
{ | |
string input; | |
int numbers[HB]; | |
int i, min; | |
printf("Поиск минимального элемента массива\n"); | |
printf("Введите в одной строке %i целых чисел и нажмите <Enter> >\n", HB); | |
for (i = 0; i < HB; i++){ | |
scanf("%i", &numbers[i]); | |
} | |
min = numbers[0]; | |
for (i = 0; i < HB; i++){ | |
if (numbers[i] < min){ | |
min = numbers[i]; | |
} | |
} | |
printf("Минимальный элемент массива: %i\n", min); | |
printf("\nНажмите любую клавишу для выхода"); | |
getch(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment