當前位置:學問君>學習教育>考研>

微軟實習生2009筆試題目最後一題

學問君 人氣:1.12W

雖然咱被微軟給鄙視了,但是回來還是寫了寫最後一題的程序。當時只有半個小時,可我回來晃晃悠悠地寫也寫了起碼多於1個小時……看來咱跟微軟的要求差距還是蠻大的啊……哎……怨念……

微軟實習生2009筆試題目最後一題

 

// : 定義控制檯應用程序的入口點。
//

#include "stdafx.h"

#define BUFMAX 100

//Find frequency of words of in
void Find (string &filenameA, string &filenameB)
{
 string tempA, tempB;
 char chA[BUFMAX], chB[BUFMAX];
 int cnt = 0, match = 0;
 
 if ( (th()==0) || (th()==0) )
 {
  cout << "Invalid input filename!" << endl;
  return ;
 }
 
 ifstream infileA ( filenameA.c_str() );
 ifstream infileB ( filenameB.c_str() );

 if ( () || () )
 {
  cout << "Cannot open input files!" << endl;
  return ;
 }

 while ( getline(infileB, tempB) )
 {
  memcpy ( chB, tempB.c_str(), th()+1 );
  cnt = 0;

  g (0, ios::beg);

  while ( !() )
  {
   infileA >> tempA;
   
   if (tempA == tempB)
    cnt++;
   else
   {
    memcpy (chA, tempA.c_str(), th()+1);

    match = 1;
    
    for (int i=0, j=0; ; i++, j++)
    {

     if (!chB[i] && !chA[j])
      break;

     else if ( !( chB[i] && chA[j] ))
     {
      match = 0;
      break;
     }

 

     if (chB[i] == '?')
      continue;

     else if (chB[i] == '*')
      for (;chA[j+1]!=chB[i+1];j++)
      {
       if (chA[j+1] == '