¡¡¡¡×òÌìдÁËÒ»¸ö³ÌÐò£¬Ö»ÄܽâÎö¼òµ¥µÄlrcÎļþ£¬ÎÒÓÐÐÞ¸ÄÁËһЩԴ³ÌÐò£¬ÏÖÔÚ¿ÉÒÔ½âÎöºÜ¶à¸ñʽµÄlrcÎļþ£¬²¢ÅªºÃ¸è´ÊµÄ˳Ðò
/**
* create by: w397090770
* Email:wyphao.2007£À163.com
* create data: 2012.3.27
**/
££include //for printf£¬fgets...
££include //for exit
££include //for vector
££include //for strlen
££include //for string
££include //for sort
££define MAXLINE 256
using namespace std;
typedef struct Number{
int time;//¸è´Êʱ¼ä
int line;//ËùÔÚÐÐ
};
static int LINE = 0;//¼Ç¼¸è´ÊËùÔÚµÄÐÐ
int LRCPrase£¨char *str£¬ vector &sentences£¬ vector &songTime£©;
int strtoint£¨char *str£©;
int operator
int main£¨int argc£¬ char *argv[]£©{
char buf[MAXLINE];
vector sentences£¬ finalSentence;
vector songTime;
FILE *fd;
//fd = fopen£¨"Àî»ÛÕä - °®ËÀÁË×òÌì.lrc"£¬ "r"£©;
//fd = fopen£¨"Áú÷×Ó - Äã°Ñ°®Çé¸øÁËË.lrc"£¬ "r"£©;
fd = fopen£¨"С»¢¶Ó - ÔÙ¼û.lrc"£¬ "r"£©;
//fd = fopen£¨"ÍõÄý¶ - ÑÛÀáµÄ´í¾õ.lrc"£¬ "r"£©;
if£¨fd == NULL£©{
perror£¨"open file"£©;
exit£¨1£©;
}
//´¦Àí¸è´Ê
while£¨fgets£¨buf£¬ sizeof£¨buf£©£¬ fd£© != NULL£©{
LRCPrase£¨buf£¬ sentences£¬ songTime£©;
}
sort£¨songTime.begin£¨£©£¬ songTime.end£¨£©£©;//°´ÕÕʱ¼äÅÅÐò
//printf£¨"£¥d
"£¬ sentences.size£¨£©£©;
/*vector::iterator it = sentences.begin£¨£©;
for£¨; it != sentences.end£¨£©; it++£©{
//printf£¨"£¥d£¬£¥d"£¬ £¨*it£©.time£¬ £¨*it£©.line£©;
printf£¨"£¥s"£¬ £¨*it£©.c_str£¨£©£©;
}*/
//°´Ê±¼ä˳ÐòÅÅÐò¸è´Ê
vector::iterator it1 = songTime.begin£¨£©;
for£¨; it1 != songTime.end£¨£©; it1++£©{
//printf£¨"£¥d£¬£¥d
"£¬ £¨*it1£©.time£¬ £¨*it1£©.line£©;
finalSentence.push_back£¨sentences[£¨*it1£©.line]£©;
}
it1 = songTime.begin£¨£©;
vector::iterator it = finalSentence.begin£¨£©;
for£¨; it1 != songTime.end£¨£© && it != finalSentence.end£¨£©; it1++£¬ it++£©{
printf£¨"£¥d£¬£¥d£¥s"£¬ £¨*it1£©.time£¬ £¨*it1£©.line£¬ £¨*it£©.c_str£¨£©£©;
}
return 0;
}
int LRCPrase£¨char *str£¬ vector &sentences£¬ vector &songTime£©{
if£¨strlen£¨str£© == 1£©{//¿ÕÐÐ
return 0;
}else{
char *p£¬ *q£¬ *temp;
q = str;
//´¦Àíʱ¼äµÄ
while£¨£¨p = strchr£¨q£¬ ""[""£©£© != NULL && £¨temp = strchr£¨q£¬ ""]""£©£© != NULL£©{
q = p + 1;
q[temp - q] = ""