• 洛谷题单——【入门1】顺序结构


    【入门1】顺序结构

    #include <stdio.h>
    int main(){
    	int a,b;
    	scanf("%d %d",&a,&b);
    	printf("%d
    ",a+b);
    	return 0;
    } 
    
    #include <stdio.h>
    int main(){
    	printf(
    	"                ********
    "
    	"               ************
    "
    "               ####....#.
    "
    "             #..###.....##....
    "
    "             ###.......######              ###            ###
    "
    "                ...........               #...#          #...#
    "
    "               ##*#######                 #.#.#          #.#.#
    "
    "            ####*******######             #.#.#          #.#.#
    "
    "           ...#***.****.*###....          #...#          #...#
    "
    "           ....**********##.....           ###            ###
    "
    "           ....****    *****....
    "
    "             ####        ####
    "
    "           ######        ######
    "
    "##############################################################
    "
    "#...#......#.##...#......#.##...#......#.##------------------#
    "
    "###########################################------------------#
    "
    "#..#....#....##..#....#....##..#....#....#####################
    "
    "##########################################    #----------#
    "
    "#.....#......##.....#......##.....#......#    #----------#
    "
    "##########################################    #----------#
    "
    "#.#..#....#..##.#..#....#..##.#..#....#..#    #----------#
    "
    "##########################################    ############
    "
    	);	
    	return 0;
    }
    
    #include <stdio.h>
    int main(){
    	int a,b;
    	scanf("%d %d",&a,&b);
    	printf("%d
    ",a*b);
    	return 0;
    }
    
    #include <stdio.h>
    int main(){
    	char a;
    	scanf("%c",&a);
    	printf("%c",a-32);
    	return 0;
    }
    
    #include <stdio.h>
    int main(){
    	//方法一 : 
    //	double a;
    //	scanf("%lf",&a);
    //	int b = a*10;
    //	int c = b%10;	//最后一位
    //	int d = b/1000;	//第一位
    //	int e = b/100%10;	//第二位
    //	int f = b/10%100%10;	//第三位
    //	printf("%d.%d%d%d",c,f,e,d); 
    	
    	//方法二:
    	char a,b,c,d;
    	scanf("%c %c %c.%c",&a,&b,&c,&d);
    	printf("%c.%c%c%c
    ",d,c,b,a); 
    	return 0;
    }
    
    #include <stdio.h>
    int main(){
    	double t,n,sum=0;
    	scanf("%lf %lf",&t,&n);
    	printf("%.3lf
    %.0lf",t/n,n*2);
    	return 0;
    }
    
    #include <stdio.h>
    int main(){
    	int a,b,c,d;
    	scanf("%d %d %d %d",&a,&b,&c,&d);
    	int p = (c-a)*60+d-b;
    	printf("%d %d
    ",p/60,p%60);
    	return 0;
    }
    
    #include <iostream>
    #include <math.h>
    using namespace std;
    int main(){
    	int n,j=0,a[2],b=1;
    	cin >> n;
    	double pi = 3.141593,sum = 0;
    	switch(n){
    		case 1:
    			cout << "I love Luogu!
    ";
    			break;
    		case 2:
    			cout << 2+4 << " " << 10-2-4;
    			break;
    		case 3:
    			cout << 14/4 << "
    " << 14-(14%4) << "
    " << 14%4;
    			break;
    		case 4:
    			cout << 166.667;
    			break;
    		case 5:
    			cout << (260+220)/(12+20);
    			break;	
    		case 6:
    			cout << sqrt(6*6+9*9);
    			break;
    		case 7:
    			cout << 110 << "
    " << 90 << "
    " << 0; 
    			break;
    		case 8:
    			cout << 2*5*pi << "
    " << 5*5*pi << "
    " << 4.0/3*5*5*5*pi;
    			break;
    		case 9:
    			for(int i=1;i<4;i++){
    				b=(b+1)*2;
    			}
    			cout << b;
    			break;
    		case 10:
    			cout << 9;
    			break;	
    		case 11:
    			cout << 100.0/3;
    			break;
    		case 12:
    			cout << 'M' - 'A' + 1 << "
    ";
    			cout << (char)('A' + 18 - 1);
    			break;
    		case 13:
    			sum = 4.0 / 3 * (4 * 4 * 4 + 10 * 10 * 10) * pi;
    			cout << (int)pow(sum,1.0 / 3);
    			break;
    		case 14:
    			for(int i = 1; i < 100; i++){
    				if ((110 - i) * (10 + i) == 3500){
    					a[j++] = 110 - i;
    				}
    			}
    			if (a[0] >= a[1])
    				cout << a[1];
    			else
    				cout << a[0];
    			break;					
    	}
    	return 0;
    }
    
    #include <stdio.h>
    #include <math.h>
    int main(){
    	double a,b,c;
    	scanf("%lf %lf %lf",&a,&b,&c);
    	double p = 1.0/2*(a+b+c);
    	double sum = p*(p-a)*(p-b)*(p-c);
    	printf("%0.1lf
    ",sqrt(sum));
    	return 0;
    }
    
    #include <stdio.h>
    int main(){
    	int a,b;
    	scanf("%d %d",&a,&b);
    	int p = 1*10+9;
    	int sum = a*10+b;
    	printf("%d
    ",sum/p);
    	return 0; 
    }
    
    /*
    1.吃过的苹果不管有没有吃完都不算完整
    2.0分钟一个苹果相当于不吃
    3.在规定时间内提前把苹果吃完了
    */
    #include <stdio.h>
    int main(){
    	int m,t,s;
    	scanf("%d %d %d",&m,&t,&s);
    	if(t==0){	//不吃 
    		printf("%d
    ",m);
    	}else{
    		int a=s/t;
    		if(s%t != 0){	//没吃完的 
    			a++;
    		} 
    		int b=m-a;
    		if(b<0){	//规定时间内吃完了 
    			printf("0
    ");
    		}else{
    			printf("%d
    ",b);
    		}
    	}
    	return 0;
    }
    

    这道题是本节最难想到的,主要是思路!!!

    /*
    首先由于不会有三条对角线交于一点,所以过某一个交点有且只能有2条对角线
    而这两条对角线实质上是确定了4个顶点(也可以看做是一个四边形的两条对角线交于一点,求四边形的数量)。
    因此只需要确定4个顶点就得到了这个唯一确定的交点。
    因此只需要求这样4个顶点的搭配有多少个了,也就是从n个顶点中取4个出来。
    根据推导:第一次取可以n个点都是可以取的,第二次取的时候第一个取的点就不能取了,所以只能取(n-1)种,
    以此类推。 由于改变四个点的顺序不会改变对角线,因此是求的组合而不是排列,也就要除以4,也就是/2/4 
    于是我们就得到了公式: n*(n-1)/2*(n-2)/3*(n-3)/4
    */
    #include <stdio.h>
    int main(){
    	unsigned long long n; //此处必须用限制条件,不然范围不够 
    	scanf("%lld",&n);
    	printf("%lld
    ",n*(n-1)/2*(n-2)/3*(n-3)/4);
    	return 0;
    } 
    
  • 相关阅读:
    SlidingMenu官方实例分析2——BaseActivity
    SlidingMenu官方实例分析1——ExampleListActivity
    SlidingMenu——使用前的配置
    获得String形式日期的后一天
    android中TabHost和RadioGroup
    android中文字斜着显示
    OpenGL ES andoid学习————2
    OpenGL ES andoid学习————1
    Gallery学习————检测手机中是否存在外部存储设备
    Java读取xml数据
  • 原文地址:https://www.cnblogs.com/gh110/p/13755804.html
Copyright © 2020-2023  润新知