一、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 问题描述
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. 分