第三次上机——作业

一问题及代码

/*   
* 文件名称:Ex3-1.cpp   
* 作 者:杨亮  
* 完成日期:2017 年 4 月 7 日   
* 版 本 号:v1.0   
* 对任务及求解方法的描述部分:   
* 输入描述:输入个人收入   
* 问题描述:根据我国所制定的个人所得税7级计算,得出个人所要缴纳的税  
* 程序输出:输入个人所得税  
* 问题分析:略   
* 算法设计:略   
*/ 
     #include <iostream>           
using namespace std;        
int main( )        
{        
    double dI,dT=0,    
           a, b ;       
    cout<<"输入您本月的收入:";        
    cin>>dI;        
    if(dI<1500+3500)      
    {      
        a=0.03;      
        b=0;      
    }      
    else if(dI<4500+3500)      
    {      
        a=0.1;      
        b=105;      
    }      
    else if(dI<9000+3500)      
    {      
        a=0.2;      
        b=555;      
    }      
    else if(dI<35000+3500)      
    {      
        a=0.25;      
        b=1005;      
    }      
    else if(dI<55000+3500)      
    {      
        a=0.3;      
        b=2755;      
    }      
    else if(dI<80000+3500)      
    {      
        a=0.35;      
        b=5505;      
    }      
    else      
    {      
        a=0.45;      
        b=13505;      
    }      
    dT=(dI-3500)*a-b;      
    cout<<"您本月应缴纳个人所得税: "<<dT<<"(元)\n";        
    return 0;        
}  

运行结果  


一问题及代码

    /*     
* 文件名称:Ex2.cpp     
* 作    者:杨亮    
* 完成日期:2017 年 4月 7日     
* 版 本 号:v1.0     
* 对任务及求解方法的描述部分:    
* 输入描述:无     
* 问题描述:本月有几天  
* 程序输出:天数  
* 问题分析:略    
* 算法设计:略     
*/     
#include<iostream>    
using namespace std;    
int main()    
{    
    int year,month,day;    
    cout<<"请输入年:";    
    cin>>year;    
    cout<<"请输入月:";    
    cin>>month;    
    if ((year%4==0&&year%100!=0)||year%400==0)    
    {    
        switch (month)    
        {    
        case 1:    
        case 3:    
        case 5:    
        case 7:    
        case 8:    
        case 10:    
        case 12:day=31;break;    
        case 2:day=29;break;    
        case 4:    
        case 6:    
        case 9:    
        case 11:day=30;break;    
        }    
    }    
    else    
    {    
        switch (month)    
        {    
        case 1:    
        case 3:    
        case 5:    
        case 7:    
        case 8:    
        case 10:    
        case 12:day=31;break;    
        case 2:day=28;break;    
        case 4:    
        case 6:    
        case 9:    
        case 11:day=30;break;    
        }    
    }    
    cout<<"此月有"<<day<<"天"<<endl;    
        return 0;    
}    

运行结果

三问题及代码

/*   
* 文件名称:Ex3-3.cpp   
* 作 者:杨亮   
* 完成日期:2017 年 4 月 4 日   
* 版 本 号:v1.0   
* 对任务及求解方法的描述部分:   
* 输入描述:输入存款的金额  
* 问题描述:输入存款金额和时间,得出到期的利息和本息共计多少元  
* 程序输出:输出到期的利息和本息共计多少元  
* 问题分析:略   
* 算法设计:略   
*/      
#include<iostream>    
using namespace std;    
int main()    
{    
  double money,interest;    
  int number;    
  cout<<"欢迎使用利息计算器!"<<endl;    
  cout<<"请输入存款金额:";    
  cin >>money;    
  cout<<"======存款金额======"<<endl;    
  cout<<"1. 3个月"<<endl;    
  cout<<"2. 6个月"<<endl;    
  cout<<"3. 一年" <<endl;    
  cout<<"4. 二年" <<endl;    
  cout<<"5. 三年" <<endl;    
  cout<<"6. 五年" <<endl;    
  cout<<"请输入存款期限的代号:";    
  cin>>number;    
  switch (number)    
  {    
   case 1 :interest=money*0.25*0.031;break;    
   case 2 :interest=money*0.50*0.033;break;    
   case 3 :interest=money*1.00*0.035;break;    
   case 4 :interest=money*2.00*0.044;break;                              
   case 5 :interest=money*3.00*0.050;break;     
   case 6 :interest=money*5.00*0.055;break;         
  }    
  cout<<"到期利息为:"<<interest<<",本息合计共"<<money+interest<<"元。"<<endl;    
  cout<<"感谢您的使用,欢迎下次光临!"<<endl;    
   return 0;    
 }    
    运行结果 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
模式识别第一章作业题,中科院刘成林,Question 1 (Pattern Classification, Chapter 2, Problem 12) Let ωmax(x) be the state of nature for which P(ωmax|x) ≥ P(ωi|x) for all i, i = 1,...,c. (a) Show that P(ωmax|x) ≥ 1/c (b) Show that for the minimum-error-rate decision rule the average probability of error is given by P(error) = 1−RP(ωmax|x)p(x)dx (c) Use these two results to show that P(error) ≤ (c−1)/c (d) Describe a situation for which P(error) = (c−1)/c Question 2 (Pattern Classification, Chapter 2, Problem 13) In many pattern classification problems one has the option either to assign the pattern to one of c classes, or to reject it as being unrecognizable. If the cost for rejects is not too high, rejection may be a desirable action. Let λ(αi|ωi) =     0 i = j i,j = 1,...,c λr i = c + 1 λs otherwise where λr is the loss incurred for choosing the (c + 1)th action, rejection, and λs is the loss incurred for making a substitution error. Show that the minimum risk is obtained if we decide ωi if P(ωi|x) ≥ P(ωi|x) for all j and if P(ωi|x) ≥ 1− λr λs , and reject otherwise. What happens if λr = 0? What happens if λr > λs? Question 3 Now we have N samples, and each sample xi, i = 1,...,N has d-dimensions. Please provide us the proofs and the pseudo-codes of PCA algorithm Question 4 (Pattern Classification, Chapter 2, Problem 10) Consider the following decision rule for a two-category one-dimensional problem: Decide ω1 if x > θ; otherwise decide ω2. (a)Showtheprobabilityoferrorforthisruleisgivenby P(error) = P(ω1)Rθ−∞p(x|ω1)dx+P(ω2)R∞ θ p(x|ω2)dx (b) By differentiating, show that a necessary condition to minimize P(error) is that θ satisfy p(θ|ω1)P(ω1) = p(θ|ω2)P(ω2) (c) Does this equation define θ uniquely? (d) Give an example where a value of θ satisfying the equation actually maximizes the probability of error. Question 5 (Pattern Classification, Chapter 2, Problem 24) Consider the multivariate normal density for which σij = 0 and σii = σ2 i , i.e., Σ = diag(σ2 1,σ2 2,...,σ2 d). (a) Show that
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值