"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)