Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. int main()
  6. {
  7.     char cristo[20] = "";
  8.     int type = 0;
  9.     char stringa[10] = "stringa";
  10.     char valore[10]= "valore";
  11.     int i = 0;
  12.     int len = 0;
  13.     char flag[10] = "";
  14.     char flag2[10] = "";
  15.     int j = 0;
  16.     char flag3[10] = "";
  17.     char flag4[10] = "";
  18.     char fra[10] = "fra";
  19.     char nonfra[10] = "nonfra";
  20.     int lenvalore = 0;
  21.     int lenstringa = 0;
  22.     int lenfra = 0;
  23.     int lennonfra = 0;
  24.  
  25.    
  26.     printf ("########################################################\n");
  27.     printf ("#                                                      #\n");
  28.     printf ("#                 Programma per Fra <3                 #\n");
  29.     printf ("#                                                      #\n");
  30.     printf ("#          </>     - By claxon007 -     </>            #\n"); 
  31.     printf ("#                                                      #\n");          
  32.     printf ("########################################################\n");
  33.     printf ("#                                                      #\n");
  34.     printf ("# - Digita '1' per inserire un valore.                 #\n");
  35.     printf ("# - Digita '2' per fare il clear della schermata.      #\n");
  36.     printf ("# - Digita '3' per ricominciare.                       #\n"); 
  37.     printf ("# - Digita '4' per uscire.                             #\n");
  38.     printf ("#                                                      #\n");
  39.     printf ("########################################################\n");
  40.     printf ("\n");
  41.     printf ("Inserisci il tuo valore: ");
  42.     scanf ("%d", &type);
  43.    
  44.     switch (type)
  45.     {
  46.         case (1):
  47.             printf ("Vuoi inserire una stringa o un valore? Digita 'stringa' o 'valore' per scegliere: ");
  48.             gets (cristo);
  49.             len = strlen(cristo);
  50.             lenvalore = strlen (valore);
  51.             lenstringa = strlen (stringa);
  52.             if (len == lenvalore)
  53.             {
  54.                 j = 0;
  55.                 for (i = 0; i < len; i++)
  56.                 {
  57.                     if (cristo[i] == valore[i])
  58.                     {
  59.                         flag[j] = 'a';
  60.                         j++;
  61.                     }
  62.                     else
  63.                     {
  64.                         flag[j] = 'b';
  65.                         j++;
  66.                     }
  67.                 }
  68.             }
  69.             else
  70.             {
  71.                 j = 0;
  72.                 if (len == lenstringa)
  73.                 {
  74.                     for (i = 0; i < len; i++)
  75.                     {
  76.                         if (cristo[i] == stringa[i])
  77.                         {
  78.                             flag2[j] = 'a';
  79.                             j++;
  80.                         }
  81.                         else
  82.                         {
  83.                             flag2[j] = 'b';
  84.                             j++;
  85.                         }  
  86.                     }
  87.                 }
  88.                 else
  89.                 {
  90.                     printf ("ERRORE1");
  91.                 }
  92.             }
  93.             if (len == lenvalore)
  94.             {
  95.                 for (i = 0; i < len; i++)
  96.                 {
  97.                     if (flag[i] = 'b')
  98.                     {
  99.                         printf ("ERRORE2");
  100.                     }
  101.                     else
  102.                     {
  103.                         printf ("Inserisci 'fra' per far felice cla o inserisci 'nonfra' per far triste cla: ");
  104.                         gets (cristo);
  105.                         len = strlen(cristo);
  106.                         lenfra = strlen (fra);
  107.                         lennonfra = strlen (nonfra);
  108.                         if (len == lenfra)
  109.                         {
  110.                             j = 0;
  111.                             for (i = 0; i < len; i++)
  112.                             {
  113.                                 if (cristo[i] == fra[i])
  114.                                 {
  115.                                     flag3[j] = 'a';
  116.                                     j++;
  117.                                 }
  118.                                 else
  119.                                 {
  120.                                     flag3[j] = 'b';
  121.                                     j++;
  122.                                 }
  123.                             }
  124.                         }
  125.                         else
  126.                         {
  127.                             j = 0;
  128.                             if (len == lennonfra)
  129.                             {
  130.                                 for (i = 0; i < len; i++)
  131.                                 {
  132.                                     if (cristo[i] == nonfra[i])
  133.                                     {
  134.                                         flag4[j] = 'a';
  135.                                         j++;
  136.                                     }
  137.                                     else
  138.                                     {
  139.                                         flag4[j] = 'b';
  140.                                         j++;
  141.                                     }
  142.                                 }
  143.                             }
  144.                             else
  145.                             {
  146.                                 printf ("ERRORE3");
  147.                             }
  148.                         }  
  149.                     }
  150.                 }
  151.             }
  152.             else
  153.             {
  154.             if (flag2[i] = 'b')
  155.             {
  156.                 printf ("ERRORE4");
  157.             }
  158.             else
  159.             {
  160.                 printf ("PROGRAMMA");
  161.             }
  162.         }
  163.     }
  164.        
  165.     return 0;
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement