⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 toj_2999.cpp

📁 Tianjin University Online Judge 的80多道题目 .
💻 CPP
字号:
#include<cstdio>#include<cstring>#include<cstdlib>#include<iterator>#include<vector>#include<algorithm>using namespace std;#define MAXWORD 11#define MAXWORDLEN 22#define MAXTITLE 1010struct TITLE{    char word[ MAXWORD ][ MAXWORDLEN ];    int nW;    int k;} request;//titleBack[ MAXTITLE ], title[ MAXTITLE ] , request;vector < struct TITLE > titleBack[ MAXTITLE ];vector < struct TITLE > title[ MAXTITLE ];int n , m;int wordCmp( const void *a , const void *b ){    return strcmp( ( char* ) a , ( char * ) b );}bool titleCmp( TITLE * a , TITLE * b ){    return a->k - b->k;}    int main(){    int i , j , k ;    char endCh;    bool found;    while( scanf( "%d" , &n ) != EOF && n ){        for( i = 0; i < n; i++ ){            for( title[ i ].nW = 0; scanf( "%s%c" , title[ i ].word[ title[ i ].nW++ ] , &endCh ) && endCh != '\n' ; );            scanf( "%d" , &title[ i ].k );        }        stable_sort( title , title + n , titleCmp );        memcpy( titleBack , title , sizeof( title ) );        for( i = 0; i < n; i++ )            qsort( &title[ i ].word , title[ i ].nW , MAXWORDLEN , wordCmp );        scanf( "%d" , &m );        for( i = 0; i < m; i++ )            for( request.nW = 0; scanf( "%s%c" , request.word[ request.nW++ ] , &endCh ) && endCh != '\n' ; );        for( i = 0; i < n; i++ ){            found = true;            for( j = 0; j < request.nW; j++ )                if( bsearch( request.word[ j ] ,  &title[ i ].word , title[ i ].nW , MAXWORDLEN , wordCmp ) ==NULL  ){                    found = false;                    break;                }            if( found ){                for( j = 0; j < title[ i ].nW; j++ ){                    printf( "%s" , titleBack[ i ].word[ j ] );                    if( j != title[ i ].nW - 1 )                        printf( " " );                    else                        printf( "\n" );                }            }        }    }    return 0;}                                                                                                                                                                            

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -