1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#include <iostream.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>
//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();
}
|