Advertisement
steverobinson

FLAMES | PITCODERS

Jan 19th, 2011
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.77 KB | None | 0 0
  1. /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**/
  2. /*  FLAMES - Future Calculator                                      */
  3. /*  Perdicts your future relationships (Lol! Seriously??)           */
  4. /*  Coded by: PIT_CSE_CodeMachines                                  */
  5. /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**/
  6.  
  7.  
  8. #include <iostream>
  9. #include <string>
  10. #include <vector>
  11. #include <cstdlib>
  12.  
  13. using namespace std;
  14.  
  15. //Global Results Storage
  16. string results[6]={"Friends","Lovers","Affectionate","going to be Married","Enemies","Siblings"};
  17.  
  18. //Finds the number of unique charachters in the two names
  19. int findNumber(string str1,string str2)
  20. {
  21.     int number=0,i,j;
  22.     bool flag=false;
  23.  
  24.     for(j=0;j<str1.length();j++)
  25.     {
  26.         for(i=0;i<str2.length();i++)
  27.         {
  28.             if(str1[j]==str2[i])
  29.                 break;
  30.         }
  31.         if(i==str2.length())
  32.             number++;
  33.     }
  34.  
  35.     for(j=0;j<str2.length();j++)
  36.     {
  37.         for(i=0;i<str1.length();i++)
  38.         {
  39.             if(str2[j]==str1[i])
  40.                 break;
  41.         }
  42.         if(i==str1.length())
  43.             number++;
  44.     }
  45.  
  46.     return number;
  47.  
  48. }
  49.  
  50. //Evaluates the FLAMES algorithm
  51. string flames(int unique)
  52. {
  53.     int n=6,x,y;
  54.     string flamesString("Xflames");
  55.     string::iterator itr=flamesString.begin();
  56.     int i=unique;
  57.     cout<<"\n-----------------------------------------------------------\nPlease wait while the computer ";
  58.     cout<<"calculates your Future\n-----------------------------------------------------------";
  59.     while(n!=1)
  60.     {
  61.         while(i>n)
  62.             i-=n;
  63.         itr+=(i);
  64.         flamesString.erase(itr);
  65.  
  66.         cout<<endl<<flamesString.substr(1,(flamesString.length()-1));
  67.  
  68.         //Delay   -------->Incase you have an "Extraordinary" processor , please increase the values below!!
  69.         for(x = 0; x < 1000; x++)
  70.             for(y = 0; y < 100000; y++);
  71.         //End Delay
  72.  
  73.         n--;
  74.         i=i+unique-1;
  75.         itr=flamesString.begin();
  76.     }
  77.  
  78.     return flamesString;
  79. }
  80.  
  81. //Function that is used to select appropriate result from Global Results Storage
  82. string resultsSender(char res)
  83. {
  84.     switch(res)
  85.     {
  86.         case 'f':
  87.             return results[0];
  88.         case 'l':
  89.             return results[1];
  90.         case 'a':
  91.             return results[2];
  92.         case 'm':
  93.             return results[3];
  94.         case 'e':
  95.             return results[4];
  96.         case 's':
  97.             return results[5];
  98.  
  99.     }
  100.  
  101. }
  102.  
  103. //The Main Function
  104. int main()
  105. {
  106.     string nameOne,nameTwo,result;
  107.     int uniqueChars;
  108.     char choice;
  109.     cout<<"-----------------------------------------------------------\n\t\tFLAMES";
  110.     cout<<"- Future Calculator\n-----------------------------------------------------------\n";
  111.  
  112. getnames:
  113.     cout<<"\nEnter Name 1: ";
  114.     cin>>nameOne;
  115.     cout<<"\nEnter Name 2: ";
  116.     cin>>nameTwo;
  117.  
  118.     //Are you serious?? :-O
  119.     if(nameOne.compare(nameTwo)==0)
  120.     {
  121.         cout<<"\nPlease try with two different people! :-O \nTry again....";
  122.         goto getnames;
  123.     }
  124.  
  125.  
  126.     //Call to function that returns number of unique chars
  127.     uniqueChars =findNumber(nameOne,nameTwo);
  128.  
  129.     //Call to function that returns the remaining character in the FLAMES string
  130.     result=flames(uniqueChars);
  131.  
  132.     //Call to function that returns the result string(your future!)
  133.     result = resultsSender(result[1]);
  134.  
  135.     cout<<"\n-----------------------------------------------------------\nComputation Completed!\n-----------------------------------------------------------";
  136.     cout<<"\n\nYou Both are "<<result;
  137.  
  138.  
  139.     cout<<"\n\nTry Again?? <y/n>.....";
  140.     cin>>choice;
  141.  
  142.     if(choice=='y'||choice=='Y')
  143.         goto getnames;
  144.  
  145.     return 0;
  146. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement