C++ Primer Plus第六版课后编程答案2.6–2.7


 

 

 

2.6

#include <iostream.h>
double change(double y);
int main()
{
 cout<<"Enter the number of light years:\n";
 double n;
 cin>>n;
 cout<<"Your number is"<<n<<endl;
 cout<<"==="<<change(n);
 cin.get();
 cin.get();
 return 0;
     
    
    
}

double change(double y)
{
       
      return y*62340;       
} 

2.7

//7
#include <iostream.h>
void see(int h,int m);
int main()
{
    cout<<"Enter the number of hours:";
    int h;
    cin>>h;
   // cout<<  h<<endl;
    cout<<"Enter the number of minutes:";
    int m;
    cin>>m;
    //cout<<m<<endl;
    see(h,m);
    cin.get();
    cin.get();
    cin.get();
    cin.get();
    return 0;
    
    
}

void see(int h,int m)
{
 cout<<"Time"<<h<<":"<<m<<endl;     
}

 

 


发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注