2021-10-01每日刷题打卡

本文探讨了如何用编程解决财务问题,通过计算 Larry 12个月银行账户的平均余额(FinancialManagement),以及如何利用递归实现LeetCode中的回文链表判断(数据结构)。涉及关键概念如投资组合管理、账户余额和回文链表算法。
摘要由CSDN通过智能技术生成

一、ZOJ-1048:Financial Management

1.1 问题描述

Larry graduated this year and finally has a job. He’s making a lot of money, but somehow never seems to have enough. Larry has decided that he needs to grab hold of his financial portfolio and solve his financing problems. The first step is to figure out what’s been going on with his money. Larry has his bank account statements and wants to see how much money he has. Help Larry by writing a program to take his closing balance from each of the past twelve months and calculate his average account balance.

题目大意:

计算12个月,每月的账户的平均余额

1.2 问题解决

#include <iostream>
using namespace std;

double b[13];
double a = 0;
int main()
{
    for(int i = 0; i < 12; i++)
    {
        cin >> b[i];
        a += b[i];
    }
    
    cout << '$' << a/12 << endl;

    system("pause");
    return 0;
}

二、Leetcode-234:回文链表

2.1 问题描述

img

2.2 问题解决

/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode() : val(0), next(nullptr) {}
 *     ListNode(int x) : val(x), next(nullptr) {}
 *     ListNode(int x, ListNode *next) : val(x), next(next) {}
 * };
 */
class Solution {
public:
    bool isPalindrome(ListNode* head) {
        vector<int> v;
        while(head != nullptr)
        {
            v.push_back(head->val);
            head = head->next;
        }
        
        for(int i = 0, j = v.size() - 1; i <  j; i++, j--)
        {
            if(v[i] != v[j])
                return false;
        }

        return true;
    }
};

三、生词

  • grab hold of 抓住

  • portfolio n. 投资组合

  • balance n. 余额

  • closing balance 期末余额

  • partucular adj. 特定的

  • penny n. 分

四、参考文章

  1. 回文链表
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值