SHARE
TWEET

s24kysymys.c

Turpo-Urpo Jun 25th, 2020 742 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main() {
  5.     char op;
  6.     char kaava[20];
  7.     printf("\e[0;91m");
  8.     printf("\n SYÖTÄ LASKUKAAVA\n");
  9.     printf("\e[0;32m");
  10.     printf(" Vähennyslasku (x-y)\n");
  11.     printf(" Yhteenlasku (x+y)\n");
  12.     printf(" Kertolasku (x*y)\n\n");
  13.     printf(" Kaavasi: \e[0;97m");
  14.     scanf("%s", kaava);
  15.     if (strstr(kaava, "-")!=NULL) { op=1; };
  16.     if (strstr(kaava, "+")!=NULL) { op=2; };
  17.     if (strstr(kaava, "*")!=NULL) { op=3; };
  18.    
  19.     switch (op) {
  20.         case 1: { printf("\e[0;91m\n Vähennyslasku"); break; };
  21.         case 2: { printf("\e[0;91m\n Yhteenlasku"); break;};
  22.         case 3: { printf("\e[0;91m\n Kertolasku"); break;};
  23.         default: { printf("\e[0;91m\n Jotain muuta"); break;};
  24.     };
  25.     printf("\e[0m");
  26. return 0;
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top