steverobinson

FLAMES | PITCODERS

Jan 20th, 2011
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.17 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.     //New Delay Algorithm!!!! Waits exactly for one sec. Thanks to Daniweb.com!!!
  73.          time(&start_time);
  74.          do
  75.          {
  76.                  time(&cur_time);
  77.          }
  78.          while((cur_time - start_time) < 1);
  79.  
  80.  
  81.  
  82.  
  83. //        //Delay   -------->Incase you have an "Extraordinary" processor , please increase the values below!!
  84. //        for(x = 0; x < 1000; x++)
  85. //            for(y = 0; y < 100000; y++);
  86. //        //End Delay
  87.  
  88.         n--;
  89.         i=i+unique-1;
  90.         itr=flamesString.begin();
  91.     }
  92.  
  93.     return flamesString;
  94. }
  95.  
  96. //Function that is used to select appropriate result from Global Results Storage
  97. string resultsSender(char res)
  98. {
  99.     switch(res)
  100.     {
  101.         case 'f':
  102.             return results[0];
  103.         case 'l':
  104.             return results[1];
  105.         case 'a':
  106.             return results[2];
  107.         case 'm':
  108.             return results[3];
  109.         case 'e':
  110.             return results[4];
  111.         case 's':
  112.             return results[5];
  113.  
  114.     }
  115.  
  116. }
  117.  
  118. //The Main Function
  119. int main()
  120. {
  121.     string nameOne,nameTwo,result;
  122.     int uniqueChars;
  123.     char choice;
  124.     cout<<"-----------------------------------------------------------\n\t\tFLAMES";
  125.     cout<<"- Future Calculator\n-----------------------------------------------------------\n";
  126.  
  127. getnames:
  128.     cout<<"\nEnter Name 1: ";
  129.     cin>>nameOne;
  130.     cout<<"\nEnter Name 2: ";
  131.     cin>>nameTwo;
  132.  
  133.     //Are you serious?? :-O
  134.     if(nameOne.compare(nameTwo)==0)
  135.     {
  136.         cout<<"\nPlease try with two different people! :-O \nTry again....";
  137.         goto getnames;
  138.     }
  139.  
  140.  
  141.     //Call to function that returns number of unique chars
  142.     uniqueChars =findNumber(nameOne,nameTwo);
  143.  
  144.     //Call to function that returns the remaining character in the FLAMES string
  145.     result=flames(uniqueChars);
  146.  
  147.     //Call to function that returns the result string(your future!)
  148.     result = resultsSender(result[1]);
  149.  
  150.     cout<<"\n-----------------------------------------------------------\nComputation Completed!\n-----------------------------------------------------------";
  151.     cout<<"\n\nYou Both are "<<result;
  152.  
  153.  
  154.     cout<<"\n\nTry Again?? <y/n>.....";
  155.     cin>>choice;
  156.  
  157.     if(choice=='y'||choice=='Y')
  158.     {
  159.         goto getnames;
  160.         system("cls");
  161.     }
  162.  
  163.  
  164.     return 0;
  165. }
Add Comment
Please, Sign In to add comment