zoukankan      html  css  js  c++  java
  • 蓝桥杯刷题2020_2_27

    T1

    一道模拟题

    高精度算阶乘

    #include <bits/stdc++.h>
    using namespace std;
    void f(int n){
    	if(n == 1){
    		cout << "1";
    	}		
    	else {
    		int a[100000];
    		int e = 0, s = 0, p = 0;
    		a[0] = 1;
    		for(int i = 2; i <= n; ++i){
    			for(int j = s; j <= e; ++j){
    				p = a[j] * i + p;
    				a[j] = p % 10;
    				p /= 10;
    			}
    			while(p != 0){//这部处理十分重要 因为并不知道会进多少位
    				e++;
    				a[e] = p % 10;
    				p /= 10;
    			}
    		}	
    		for(int i = e; i >= 0; --i)
    			cout << a[i];
    	}
    }
    int main (){
    	int n;
    	cin >> n;
    	f(n);
    	cout << endl;
    	return 0;
    }
    

     T2

    sb题

    复习一下transform函数

        #include <bits/stdc++.h>
    	using namespace std;
    
    	int main (){
    		string a, b;
    		cin >> a >> b;
    		string c = a;
    		string d = b;
    		transform(c.begin(), c.end(), c.begin(), ::toupper);
    		transform(d.begin(), d.end(), d.begin(), ::toupper);
    		if(a.size() != b.size()){
    			cout << 1 << endl;
    		}
    		else if(a == b) {
    			cout << 2 << endl;
    		}
    		else if(c == d){
    			cout << 3 << endl;
    		}
    		else {
    			cout << 4 << endl;
    		}
    	}
    

     T3

        //矩形相交问题
    #include <bits/stdc++.h>
    using namespace std;
    int main (){
    	//本题由相交矩形的顶点来求解比较简单
    	double x1, x2, x3, x4, y1, y2, y3, y4;
    	cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    	double x = min(max(x1, x2), max(x3, x4));
    	double xx = max(min(x1, x2), min(x3, x4));
    	double y = max(min(y1, y2), min(y3, y4));
    	double yy = min(max(y1, y2), max(y3, y4));
    	if(x > xx && yy > y){
    		printf("%.2f
    ", (x - xx) * (yy - y));
    	}
    	else{
    		printf("0.00
    ");
    	}
    }
    

     ..............后面刷的一些题就不往上传了==

    作者:LightAc
    出处:https://www.cnblogs.com/lightac/
    联系:
    Email: dzz@stu.ouc.edu.cn
    QQ: 1171613053
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利。
  • 相关阅读:
    Java数组和方法
    Java数组
    Java方法升级
    Java流程控制
    Java编译器的常量优化
    chrome使用技巧(看了定不让你失望)
    C 排序法
    mysql 线程池 数据库连接池
    php mysql
    深入剖析PHP输入流 php://input (转载 http://www.nowamagic.net/academy/detail/12220520)
  • 原文地址:https://www.cnblogs.com/lightac/p/12374799.html
Copyright © 2011-2022 走看看