zoukankan      html  css  js  c++  java
  • 上机练习一

    导航:复试上机历年真题,题目未搜集全
    十四:2003 十三:2004
    十二:2005 十一:2006
    十:2007 九:2008
    八:2009 七:2012
    六:2013 五:2014
    四:2015 三:2017
    二:2018 一:2019

    一、2019

    1、税后工资

    题目:
    求扣个人所得税后的工资,不同工资段税率不同
    代码:

    #include<stdio.h> 
    
    
    int main()
    {
    	double sal, res, tax;//需要用double类型 
    	
    	scanf("%lf", &sal);
    	if(sal<1600)
    		tax = 0;
    	else if(sal>=1600&&sal<=2500)
    		tax = (sal-1600)*0.05;
    	else if(sal>2500&&sal<=3500)
    		tax = 900*0.05 + (sal-2500)*0.1;
    	else if(sal>2500&&sal<=4500)
    		tax = 900*0.05 + 1000*0.1 + (sal-2500)*0.15;
    	else if(sal>=4500)
    		tax = 900*0.05 + 1000*0.1 + 2000*0.15 + (sal-4500)*0.2;
    	
    	res = sal-tax;
    	printf("税后工资为:%.2f
    ", res);
    	
    	return 0;
    }
    
    

    2、含6数字的个数

    题目:
    100-999 中正整数有一个’6’的两个’6’的三个’6’的数的个数

    代码:

    #include<stdio.h>
    #include<string.h>
    
    
    int a[4];
    
    
    int main()
    {
    	for(int i=100;i<=999;i++)
    	{
    		int count, x, t;
    		x = i;
    		count = 0;//记录i的包含6的个数 
    		while(x!=0)
    		{
    			t = x%10;
    			x /= 10;
    			if(t==6)
    				count++;
    		}
    		if(count!=0)
    			a[count]++;			
    	}
    	printf("含一个6数字个数:%d 两个:%d 三个:%d
    ", a[1], a[2], a[3]);
    	
    	return 0;
     } 
    

    3、学生成绩

    题目:
    录入 5 名学生学号,姓名,三门成绩,一个函数 searchfail()求有不及格课程的人的学号,还有一个函数是将总分降序排序 sort()

    代码:

    #include<stdio.h>
    #include<string.h>
    #include<math.h>
    #include<algorithm>
    
    using namespace std;
    
    
    typedef struct Stu{
    	char name[10];
    	char id[10];
    	double chinese;
    	double math;
    	double english;
    	double sums;
    	Stu()
    	{
    		sums = 0;
    	}
    }Stu;
    
    
    void searchfail(Stu stu[])//输出不及格的人 
    {
    	for(int i=0;i<5;i++)
    	{
    		if(stu[i].chinese<60||stu[i].math<60||stu[i].english<60)
    			printf("%s %s不及格
    ", stu[i].id, stu[i].name);
    	}
    }
    
    
    bool cmp(Stu a, Stu b)//成绩从小到达排序 
    {
    	return a.sums<b.sums;
    }
    
    
    int main()
    {
    	Stu stu[5];
    	for(int i=0;i<5;i++)
    	{
    		scanf("%s %s %lf %lf %lf", stu[i].id, stu[i].name, &stu[i].chinese, &stu[i].math, &stu[i].english);
    		stu[i].sums = stu[i].chinese+stu[i].math+stu[i].english;
    	}
    	
    	searchfail(stu); 
    	
    	stable_sort(stu, stu+5, cmp);//稳定排序 
    	
    	printf("排序后:
    ");
    	for(int i=0;i<5;i++)
    		printf("%s %s %.2f %.2f %.2f %.2f
    ", stu[i].id, stu[i].name, stu[i].chinese, stu[i].math, stu[i].english, stu[i].sums);
    	
    	return 0;
     } 
     
     
     
    
  • 相关阅读:
    Object-C,NSSet,不可变集合
    NYIST 860 又见01背包
    NYIST 1070 诡异的电梯【Ⅰ】
    HDU 1542 Atlantis
    HDU 4756 Install Air Conditioning
    CodeForces 362E Petya and Pipes
    HDU 4751 Divide Groups
    HDU 3081 Marriage Match II
    UVA 11404 Palindromic Subsequence
    UVALIVE 4256 Salesmen
  • 原文地址:https://www.cnblogs.com/welan/p/12688532.html
Copyright © 2011-2022 走看看