Classic Algorithm (31~60)

Source: Internet
Author: User

"Program 31"
Title: Please enter the first letter of the day of the week to determine the day of the week, if the first letter, then continue
Judge the second letter.

1#include <iostream>2 using namespacestd;3 intMain ()4 {5     CharC;6Cin>>C;7     Switch(c)8     {9      Case 'M':Tencout<<"Monday"<<Endl; One          Break; A      Case 'T': -cout<<"input another letter:"; -Cin>>C; the         if(c=='u') cout<<"Tuesday"<<Endl; -         Else if(c=='h') cout<<"Thursday"<<Endl; -          Break; -      Case 'W': +cout<<"Wendesday"<<Endl; -          Break; +      Case 'F': Acout<<"Friday"<<Endl; at          Break; -      Case 'S': -cout<<"input another letter:"; -Cin>>C; -         if(c=='a') cout<<"Saturday"<<Endl; -         Else if(c=='u') cout<<"Sunday"<<Endl; in          Break; -     default: tocout<<"Input Error"<<Endl; +          Break; -     } theSystem"Pause"); *     return 0; $}

==============================================================
"Program 32"(TC can add the header file "Conio.h", but not in the VC, only manually add Textbackground ())
Title: Press any key-to-change-color, do-want to try it. Please hurry up!

1#include <iostream>2#include"windows.h"3 using namespacestd;4 intTextbackground ( Shorticolor)5 {6HANDLE HD =GetStdHandle (std_output_handle);7 Console_screen_buffer_info Csbinfo;8Getconsolescreenbufferinfo (HD, &csbinfo);9     returnSetconsoletextattribute (HD, (icolor<<4)| (csbinfo.wattributes&~0xF0));Ten } One intMain () A { -     intcolor; -     CharC; the      for(color=0; color<8; color++) -     { - textbackground (color); -cout<<"This is color"<<color<<Endl; +cout<<"Please press any key to continue."<<Endl; -Cin>>C; +     } ASystem"Pause"); at     return 0; -}

==============================================================
"Program 33" (slightly)
Title: Learning Gotoxy () and CLRSCR () functions

==============================================================
"Program 34"
Title: Practice function calls

1#include <iostream>2 using namespacestd;3 voidHello_world ();4 voidTriple_hello_world ();5 intMain ()6 {7 Triple_hello_world ();8System"Pause");9     return 0;Ten } One voidHello_world () A { -cout<<"Hello world!"<<Endl; - } the voidTriple_hello_world () - { -      for(intI=0; i<3; i++) - Hello_world (); +}

Classic Algorithm (31~60)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.