Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #include <strings.h>
- void info(){
- printf("171RDB133\n");
- printf("Lauris Štekels\n");
- printf("7.grupa\n");
- }
- float calcA(float x) {
- return logf(2 * x - 3);
- }
- float calcB(float x) {
- return (4 * x) / (x * x - 9);
- }
- void function1(float a, float b) {
- float result = logf(fabsf(b) - sqrtf(a));
- printf("%.3f\n", result);
- }
- void function2(float a, float b) {
- float result = ((a + 1) / 10) - 18 * a * b;
- printf("%.3f\n", result);
- }
- void mainTask() {
- int validation, trash;
- float x, a, b;
- printf("Ievadiet x: ");
- validation = scanf("%f", &x);
- trash = scanf("%c", &x);
- if (validation != 1) {
- printf("Invalid input!\n");
- } else {
- a = calcA(x);
- b = calcB(x);
- a < fabsf(b) ? function1(a, b) : function2(a, b);
- }
- }
- int main() {
- info();
- char cont = 'y';
- while (strcasecmp(&cont, "y") == 0) {
- mainTask();
- printf("Continue? (y or Y)\n");
- scanf("%s", &cont);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement