微软实习生笔试题目最后一题

时间:2018-12-31 12:00:00 资料大全 我要投稿

微软实习生笔试题目最后一题

虽然咱被微软给鄙视了,但是回来还是写了写最后一题的程序,

微软实习生笔试题目最后一题

。当时只有半个小时,可我回来晃晃悠悠地写也写了起码多于1个小时……看来咱跟微软的'要求差距还是蛮大的啊……哎……怨念……

微软实习生笔试题目最后一题

 

// test.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"

#define BUFMAX 100

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

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

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

  infileA.seekg (0, ios::beg);

  while ( !infileA.eof() )
  {
   infileA >> tempA;
   
   if (tempA == tempB)
    cnt++;
   else
   {
    memcpy (chA, tempA.c_str(), tempA.length()+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] == '\0')
        break;
      }

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

 

    }

    if (match)
     cnt++;
   }
  }

  cout << tempB << ' ' << cnt << endl;
 }

 infileA.close();
 infileB.close();
}

int _tmain(int argc, _TCHAR* argv[])
{
 string filenameA, filenameB;
 
 cout << "Please input two files' name:" << endl;
 cin >> filenameA >> filenameB;

 Find (filenameA, filenameB);
 
 return 0;

【微软实习生笔试题目最后一题】相关文章:

1.微软笔试题目

2.microsoft intern微软实习生笔试题目

3.有趣的微软笔试题目

4.微软实习生笔试题

5.微软暑期实习招聘笔试题目

6.微软求职笔试中考察的题目

7.微软笔试经验谈和题目细析

8.微软10道笔试面试题目