Advertisement
nRikee

Nota parcial1 d'LTP

Nov 12th, 2012
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.27 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <conio.h>
  4.  
  5. using namespace std;
  6.  
  7. string toUpperCase(string);
  8.  
  9. int main()
  10. {
  11.     char chuleta [][20] =
  12.         {
  13.             {'B','A','A','C', 'C','C','C','B', 'D','A','D','A', 'D','D','B','B', 'B','C','B','C'},
  14.             {'A','B','B','C', 'A','A','B','B', 'C','B','C','B', 'B','D','A','A', 'C','C','D','D'}
  15.         };
  16.     string auxR;
  17.     enum examen {A, B, ERROR};
  18.     int aux;
  19.  
  20.     cout << "Cual es tu examen?" << endl << "A -> 0" << endl << "B -> 1" << endl;
  21.     cin >> aux;
  22.  
  23.     cout << endl << "Introduce tu respuesta, si no has contestado alguna pon una \'x\'" << endl << "Ejemplo: \"abxac\"" << endl;
  24.     cin >> auxR;
  25.     auxR = toUpperCase(auxR);
  26.  
  27.     double be=0.0,mal=0.0;
  28.     for(int a=0;a<20;a++){
  29.         if(auxR[a]==chuleta[aux][a]) be++;
  30.         else if (auxR[a]!='X') mal++;
  31.     }
  32.  
  33.     double aux2=0, nota=0.0;
  34.     if (mal==0) aux2++; else aux2= mal/3;
  35.     nota = be - aux2;
  36.     nota = nota / 2.0;
  37.     cout << endl << "Tu puntuacion es de " << nota << endl;
  38.  
  39.     getch();
  40. }
  41.  
  42. string toUpperCase(string s){
  43.     for (unsigned int a=0;a<s.length();a++)
  44.     {
  45.         if(s[a]>=((int)'a') && s[a]<=((int)'z'))
  46.         {
  47.             s[a]= (char)(((int)s[a])-32);
  48.         }
  49.     }
  50.  
  51.     return s;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement