头像

面炸酱




离线:3小时前


最近来访(11)
用户头像
zc_1
用户头像
南岸以南南岸哀
用户头像
nixnix
用户头像
你回来了
用户头像
running_1
用户头像
冬坂五百里
用户头像
凌乱之风
用户头像
心向远方
用户头像
大家好我叫卢同学
用户头像
梦醒了

活动打卡代码 AcWing 654. 时间转换

面炸酱
3小时前
#include<iostream>

using namespace std;

int main(){
    int n;
    cin >> n;

    int hours = n / 3600;
    n %= 3600;
    int minutes = n/60;
    n %= 60;
    cout <<hours<<':'<<minutes<<':'<<n<<endl;

}


活动打卡代码 AcWing 653. 钞票

面炸酱
3小时前
#include<iostream>
using namespace std;

int main(){

    int n;
    int money[] = {100,50,20,10,5,2,1};
    int idx = 0;

    cin>>n;
    cout <<n<<endl;
    while (idx<7){
        cout << n/money[idx] << " nota(s) de R$ "<<money[idx]<<",00"<<endl;

        n %= money[idx];

        idx++;
    }

}





活动打卡代码 AcWing 616. 两点间的距离

面炸酱
4小时前
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
    double x1,y1,x2,y2;
    scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
    printf("%.4lf\n", sqrt(pow(x2-x1,2)+pow(y2-y1,2)) );
}





活动打卡代码 AcWing 615. 油耗

面炸酱
4小时前
#include <cstdio>
using namespace std;

int main(){
    double d,c;
    scanf("%lf%lf",&d,&c);
    printf("%.3lf km/l\n", d/c );
}


活动打卡代码 AcWing 609. 工资

面炸酱
4小时前
#include<cstdio>
using namespace std;

int main(){
    int num,hr;
    double pay;

    scanf("%d%d%lf",&num,&hr,&pay);
    printf("NUMBER = %d\n",num);
    printf("SALARY = U$ %.2lf\n",hr*pay);
}


活动打卡代码 AcWing 606. 平均数1

面炸酱
4小时前
#include<iostream>
#include<cstdio>

double a,b;

int main(){
    #注意输入的时候就要用%lf才是double
    scanf("%lf%lf",&a,&b);
    printf("MEDIA = %.5lf", (a*3.5+b*7.5)/11);
}


活动打卡代码 AcWing 604. 圆的面积

面炸酱
5小时前
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

double pi = 3.14159;
double r;
int main(){
cin>>r;
printf("A=%.4f", pi* pow(r,2));
}





/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 */
class Solution {
public:
    vector<int> printListReversingly(ListNode* head) {
        vector<int> st;
        ListNode* cur = head;
        while (cur){
            st.push_back(cur->val);
            cur = cur->next;
        }
        //reverse(st.begin(),st.end());
        //return st;
        return vector<int>(st.rbegin(), st.rend());
    }
};



  • 利用快排的模板,就是快速选择

  • python

class Solution(object):
    def reOrderArray(self, array):
        """
        :type array: List[int]
        :rtype: void
        """
        l = 0
        r = len(array)-1
        while l <= r:
            while l <= r and (array[l] % 2):
                l += 1
            while l <= r and (array[r] % 2 ==0):
                r -= 1
            if l <= r:
                array[l],array[r] = array[r],array[l]
                l += 1
                r -= 1
        return array



#include <iostream>

using namespace std;


class Gen0{
    public:
    //只要Gen0的print()是virtual,它的指针指向谁就用谁的print(),
    virtual void print(){
        cout <<"print Gen0"<<endl;
    }
};

class Gen1:public Gen0
{
    public:
        void print(){
            cout <<"print Gen1"<<endl;
        }
};

class Gen2:public Gen1
{
    public:
        void print(){
            cout <<"print Gen2"<<endl;
        }
};

int main(){
    Gen0* p0 = new Gen0();
    Gen1* p1 = new Gen1();
    Gen2* p2 = new Gen2();

    p0->print();
    p1->print();
    p2->print();

    p0 = p1;
    p0->print();

    p0 = p2;
    p0->print();

};
  • 输出
print Gen0
print Gen1
print Gen2
print Gen1
print Gen2