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:
";
 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;     
}




原文地址:https://www.cnblogs.com/qq84435/p/3664893.html