zoukankan      html  css  js  c++  java
  • 学习C++之父的最新姐妹作笔记2

          看了C++之父的最新作品也一段时间了,应该有半个月了,我是两本书一起看的,结合起来看的,个人认为这样看起来有助于理解,也看了好几章了,没有发现什么不大容易理解的地方,但有一个地方肯定是以前没有注意到的或者说没有接触到的。好,废话少说。

          在原理与实践的71页“蜂鸣提醒”“BLEEP”,这两个词我想有很多人不知道去如何实现,至少我不明白。经过查找MSDN c++之父要说的是这个函数Beep(--,--)

    具体函数说明如下:

    BOOL WINAPI Beep(
      __in          DWORD dwFreq,
      __in          DWORD dwDuration
    );
    

    Parameters

    dwFreq

    The frequency of the sound, in hertz. This parameter must be in the range 37 through 32,767 (0x25 through 0x7FFF).

    Windows Me/98/95:  The Beep function ignores this parameter.
    dwDuration

    The duration of the sound, in milliseconds.

    Windows Me/98/95:  The Beep function ignores this parameter.

    Return Value

    If the function succeeds, the return value is nonzero.

    If the function fails, the return value is zero. To get extended error information, call GetLastError.

    当然这个函数要包含头文件#include "windows.h"

    Example:Beep( 750, 300 );
    下面是我将书上的试一试实现的程序:
    // BLEEP.cpp : 定义控制台应用程序的入口点。
    //
    
    #include "stdafx.h"
    
    //这里我就懒得加载c++之父给我们写好的头文件了std_lib_facilities.h 因为都是比较常见的头文件
    #include "windows.h"
    #include <iostream>
    #include <string>  
    #include <vector>
    #include <algorithm>
    using namespace std;
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	vector<string> words;
    	string temp;
    	string disliked = "Broccoli";
    	while(cin>>temp)
    	{
    		if(temp == disliked)
    		{
    			/*Beep 第一个参数 The frequency of the sound, in hertz. This parameter must be in the range 37 through 32,767 (0x25 through 0x7FFF). 
    			第二个参数 The duration of the sound, in milliseconds.
    			*/
    			Beep(500,500); 
    			break;
    		}
    		words.push_back(temp);
    	}
    	cout<<"Number of words: "<<words.size()<<endl;
    
    	sort(words.begin(),words.end());//#include <algorithm>
    
    	for(int i = 0;i<words.size();i++)
    	{
    		if(i==0||words[i-1]!=words[i])
    		{
    			cout<<words[i]<<endl;
    		}
    	}
    
    	system("pause");
    	return 0;
    }
    
    
  • 相关阅读:
    最小覆盖点集模板
    NSCache使用常见错误
    stl变易算法(一)
    web.xml(8)_jsp-config
    大话设计模式—中介者模式
    HTML5开发移动web应用——SAP UI5篇(9)
    BZOJ 1588 HNOI2002 营业额统计 裸Treap
    php实现Bloom Filter
    华为上机之四
    【转】我的电脑最近忽然开不了机,启动修复也无法修复,win7系统。开机的时候如果不点启动修复直接正常启动
  • 原文地址:https://www.cnblogs.com/Daywei/p/Notes2.html
Copyright © 2011-2022 走看看