C++ primer plus Six Edition //2.7.3 答案程序

来源:互联网 发布:淘宝直播卖家申请入口 编辑:程序博客网 时间:2024/06/07 10:56
//2016.08.07
//C++ primer plus Six Edition 
//2.7.3


/*
Write a code of C++,what have three function (include main).
  And generate the following output
  
  Three blind mice
  Three blind mice
  See how they run  
  See how they run
  
  Once function of three need be called twice to output first two line.
  Another need be called twice to output last two line.
*/


#include <iostream>
using namespace std;
void mice(int);
void run(int);


 int main()
 {
 
  int a = 0;
int b = 0;

 
  //
 
  for(a=0;a<2;a++)//mice double
  {
//x = x + 1;
//mice(x);
mice(a);
}
 
 
  for(b=0;b<2;b++)//run double
  {
//y = y + 1;
  //run(y);
run(b);
}
 
  return 0;
 }
 
void mice(int n)//output"Three blind mice"
 {
// int n;
if(n<3)
cout<<"Three blind mice"<<endl;
 }
 
void run(int n)//output"See how they run"
 {
  //int y;
if(n<3)
cout<<"See how they run"<<endl;
 }
 
 /*
  This program test ¡°iostream and call of function¡± 
  I have lots of warn in this program
 
  First every loop need "{}" to definiton loop body; 
 "()"to schedulable condition.
  
    Second variables need to be defined , every variable.

third every function have there own variable

fourth 
*/
0 0
原创粉丝点击