#include <iostream>

#include <cctype>
#include <cstring>

//Function 1
void upgrade(int &acr)
{ acr=9; cout<<"\n\n>Successfully updated the file."; getch(); }


//Function 2
void search(char ch[160],char acronym[9][36],int acr)
{ int count,c=strlen(ch);
  for(int i=0;i<acr;i++)
  {
  for(int j=0;acronym[i][j]!='=';j++);
  for(int k=0;k<=c;k++)
   { for(int l=0,count=0;l<j;l++)
    if(toupper(ch[k+l])==acronym[i][l]) count++;
    if(count==j) {cout<<'\n'<<acronym[i]; break;}
   }
  }
}


//Function 3
void display (char ch[160], char acronym[9][36],int acr)
{ int i,j,k,l,count,p;
  for(i=0;i<=strlen(ch);i++)
  { for(j=0;j<acr;j++)
    { for(l=0;acronym[j][l]!='=';l++);
      for(k=0,count=0,p=0;k<l;k++)
      if(toupper(ch[i+k])==acronym[j][k]) count++;
      if(count==l) {i+=l-1; for(l+=1;acronym[j][l]!='\0';l++) cout<<acronym[j][l]; p=1; break;}
    }
    if(p==0)
    cout<<ch[i];
  }
}



// Function main()
void main()
{
clrscr();
int acr=2, c;
char ch[160], acronym[9][36]={"LOL=laughing out loud",
			      "IRL=in real life",
			      "AFK=away from keyboard",
			      "BFF=best friends forever",
			      "FWT=for the victory",
			      "IIRC=if I recall correctly",
			      "IMHO=in my humble opinion",
			      "NVM=never mind",
			      "TTYL=talk to you later"};
cout<<">Press \"u\" if you want to upgrade the program's acromyms' list. ";
c=getch();
if(c==85||c==117) upgrade(acr);
clrscr();
cout<<">Enter your tweet(max. 160 characters): "; cin.getline(ch,160);
search(ch,acronym,acr);
cout<<"\n\n>Converting user's tweet......\n\n";
display(ch,acronym,acr);
getch();
}