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

📄 ex3_17.cpp

📁 Visual C++ 2005的源代码
💻 CPP
字号:
// Ex3_17.cpp : main project file.
// Analyzing a string using a for each loop

#include "stdafx.h"

using namespace System;


int main(array<System::String ^> ^args)
{
  int vowels = 0;
  int consonants = 0;
  String^ proverb = L"A nod is as good as a wink to a blind horse.";
  for each(wchar_t ch in proverb)
  {
    if(Char::IsLetter(ch))
    {
      ch = Char::ToLower(ch);      // Convert to lowercase
      switch(ch)
      {
      case 'a': case 'e': case 'i':
      case 'o': case 'u':
        ++vowels;
        break;
      default:
        ++consonants;
        break;
      }
    }
  }
  Console::WriteLine(proverb);
  Console::WriteLine(L"The proverb contains {0} vowels and {1} consonants.",
                                                              vowels, consonants);

    return 0;
}

⌨️ 快捷键说明

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