發表文章

目前顯示的是有「String」標籤的文章

UVa 902 Password Search

解題:利用map存各個Substring的出現率,找最大的   1  #include <stdio.h>  2  #include <iostream>  3  #include <algorithm>  4  #include <string>  5  #include <vector>  6  #include <map>  7  using namespace std ;  8  int main ()  9  { 10      int n ; 11      while ( cin >> n ) 12      { 13          string str , sub ; 14          map < string , int > m ; 15          cin >> str ; 16          int len = str . length (); 17          for ( int i = 0 ; i <= len - n ; i ++) 18          { ...

UVa 230 Borrowers

解題: 麻煩的字串處理... Code: #include<stdio.h> #include<stdlib.h> #include<iostream> #include<string.h> #include<string> #include<map> #include<algorithm> #include<queue> using namespace std ; typedef pair < string , string > ss ; int main () {     char input [ 10005 ]= "" , command [ 10005 ]= "" ;     map < ss , bool > on ; ///books on shelves     map < string , string > books ; ///book and author     while ( gets ( input )&& strcmp ( input , "END" )!= 0 )     {         int len = strlen ( input ), ind = 0 , sind = 10000000 ;         char tmp [ 10005 ]= "" ;         string name = "" , author = "" ;         bool check = false , flag = false ;     ...