steverobinson

FLAMES | PITCODERS

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