Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6450e5afb | ||
|
|
acd7c3eae7 | ||
|
|
1c91ad6e9e | ||
|
|
0fc4e86a7a | ||
|
|
ca656f2803 | ||
|
|
39731c5060 |
+1
-2
@@ -3,5 +3,4 @@
|
||||
cmake-buid-debug
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
Debug
|
||||
*.exe
|
||||
@@ -8,8 +8,9 @@
|
||||
* Хромова Полина
|
||||
|
||||
## Части задачи
|
||||
- GPIO + GPIO в контексте Atmega328. Pull up, Pull down (Михаил Батухтин/Уткин Никита)
|
||||
- Физическая реализация клавиатуры (Кристина Бочкина/Полина Хромова)
|
||||
- SPI интерфейс + SPI у Atmega328 (Кристина Бочкина)
|
||||
- Программная реализация клавиатуры (Полина Хромова)
|
||||
- GPIO + GPIO в контексте Atmega328. Pull up, Pull down (Кристина Бочкина/Полина Хромова)
|
||||
- Реализация клавиатуры (Кристина Бочкина/Полина Хромова)
|
||||
- SPI интерфейс + SPI у Atmega328 (Никита Уткин)
|
||||
- Архитектура ПО (Михаил Батухтин)
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
double calculate(char op, double num1, double num2) {
|
||||
double result = 0;
|
||||
switch (op) {
|
||||
case '+':
|
||||
result = num1 + num2;
|
||||
break;
|
||||
case '-':
|
||||
result = num1 - num2;
|
||||
break;
|
||||
case '*':
|
||||
result = num1 * num2;
|
||||
break;
|
||||
case '/':
|
||||
result = num1 / num2;
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
int main() {
|
||||
double number = 0;
|
||||
double tmpNumber = 0;
|
||||
char input;
|
||||
char operator;
|
||||
while (1) {
|
||||
scanf(" %c", &input);
|
||||
switch (input) {
|
||||
case '+':
|
||||
operator = '+';
|
||||
tmpNumber = number;
|
||||
number = 0;
|
||||
break;
|
||||
case '-':
|
||||
operator = '-';
|
||||
tmpNumber = number;
|
||||
number = 0;
|
||||
break;
|
||||
case '*':
|
||||
operator = '*';
|
||||
tmpNumber = number;
|
||||
number = 0;
|
||||
break;
|
||||
case '/':
|
||||
operator = '/';
|
||||
tmpNumber = number;
|
||||
number = 0;
|
||||
break;
|
||||
case '=':
|
||||
printf("%lf\n", calculate(operator, tmpNumber, number));
|
||||
tmpNumber = 0;
|
||||
number = 0;
|
||||
break;
|
||||
case 'q':
|
||||
goto exit;
|
||||
// operator doesn't match any case constant
|
||||
default:
|
||||
number = (number * 10) + atof(&input);
|
||||
printf("%.1lf\n", number);
|
||||
}
|
||||
}
|
||||
exit:
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user