C++函数调用

#include<iostream>
using namespace std;
#include<string>

void fun1(string str, int n)
{
for(int i=0; i<n; i++)
  cout<<str<<endl;
}

void fun2()
{
    fun1("Three blind mice",2);
    fun1("See how they run",2);
}

int main()
{
    fun2();
}

#include<iostream>
using namespace std;
#include<string>

void fun(int hour, int minute)
{
if(0<=hour<24&&0<minute<10)          cout<<"Time "<<hour<<":0"<<minute<<endl; 
else if(0<=hour<24&&10<=minute<=59)  cout<<"Time "<<hour<<":"<<minute<<endl; 
else cout<<"Error"<<endl;
}




int main()
{  int h,m;
 cout<<"Enter the number of hours:";
 cin>>h;

 cout<<"Enter the number of minutes:";
 cin>>m;
 fun(h,m);

   
}

  

猜你喜欢

转载自www.cnblogs.com/wangprince2017/p/8974481.html