• C++ Primer Plus 第六版课后编程答案 2.1-2.5


    第一章没有习题


    2.1

    //p35  1
    
    #include <iostream.h>
    int main()
    {
      cout<<"我的名字啊,这是个什么啊"<<endl;
      cout<<"我家住在黄土高坡
    ";
      cin.get();
      return 0;    
        
        
    }
    

    2.2

    // 2.2
    
    #include <iostream.h>
    int main()
    {
     cout<<"输入一个以码为单位的距离
    ";
     int n;
     cin>>n;
     //cout<<n;
     cout<<"转换之后啊,看看是多少啊:
    "<<n*220<<"码"<<endl; 
     cin.get();
     cin.get();
     return 0;    
        
        
    }
    

    2.3

    //2.3
    
    #include <iostream.h>
    
    void myFuction1();
    void myFuction2() ;
    
    int main()
    {
        using namespace std;
        myFuction1(); 
        myFuction1(); 
        myFuction2(); 
        myFuction2();
        cin.get();
        return 0; 
        
        
    }
    
    void myFuction1()
    {
     cout<<"Three blind mice"<<endl;
     cout<<"Three blind mice"<<endl;      
    }
    void myFuction2()
    {
    cout<<"see how they run"<<endl; 
    cout<<"see how they run"<<endl;      
         
    }
    

    2.4


    //2.4 
    
    #include <iostream.h>
    int main()
    {
         cout<<"请输入你的年龄"<<endl;
         int age;
         cin>>age;
         cout<<"你的年龄是:"<<age<<endl;
         cout<<"包含"<<age*12<<"个月"<<endl;
         cin.get();
         cin.get();
         return 0; 
        
        
    }
    

    2.5

    //2.5
    #include <iostream.h>
    
    double change(double n);
    int main()
    {
         cout<<"please enter a Celsius valus:";
         double n;
         cin>>n;
         cout<<"
    your valus is :"<<n<<endl;
         double now=change(n);
         cout<<"now is "<<now<<endl<<change(5.2);
         cin.get();
         cin.get();
         return 0;
        
        
    }
    double change(double n)
    {
           
     return n*10;       
           
           
    }
    

    不懂可以留言,这么简单应该都懂吧





  • 相关阅读:
    发送短信/邮件/打电话 code(转)
    如何学习算法
    堆和栈的区别
    2010 baidu笔试
    关于TableView中图片的延时加载(转)
    sqlite + UITableView 实现iPhone大数据浏览
    2010 Google中国笔试试题
    海量数据处理方法总结(转)
    IPhone WebApp 设计开发工具与资源(转)
    DynamicDataSet
  • 原文地址:https://www.cnblogs.com/qq84435/p/3664894.html
Copyright © 2020-2023  润新知