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

📄 ex4_18.cpp

📁 Visual C++ 2005的源代码
💻 CPP
字号:
// Ex4_18.cpp : main project file.
// Searching for punctuation

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)
{
  array<wchar_t>^ punctuation = {L'"', L'\'', L'.', L',', L':', L';', L'!', L'?'};
  String^ sentence = L"\"It's chilly in here\", the boy's mother said coldly.";

  // Create array of space characters same length as sentence
  array<wchar_t>^ indicators = gcnew array<wchar_t>(sentence->Length){L' '};

  int index = 0;                       // Index of character found
  int count = 0;                       // Count of punctuation characters
  while((index = sentence->IndexOfAny(punctuation, index)) >= 0)
  {
    indicators[index] = L'^';          // Set marker
    ++index;                           // Increment to next character
    ++count;                           // Increase the count
  }
  Console::WriteLine(L"There are {0} punctuation characters in the string:",
                                                                          count);
  Console::WriteLine(L"\n{0}\n{1}", sentence, gcnew String(indicators));
  return 0;
}

⌨️ 快捷键说明

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