微软实习生笔试题

时间:2022-12-09 17:23:29 笔试题目 我要投稿
  • 相关推荐

微软实习生笔试题

// 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;
     }
 

【微软实习生笔试题】相关文章:

微软笔试题08-13

微软的笔试试题07-31

微软笔试题及分析07-31

2015微软笔试题07-31

2011微软笔试题07-20

详细的微软试题及解答08-08

微软笔试题目03-16

微软面试题07-25

微软面试题目07-31

微软面试试题大家谈07-31