C++
HanSmileLiao
追逐繁星
展开
-
求某个日期是这一年中的第几天
前几天在备赛时看到高斯日记这个问题,现在写了一个求某个日期是当年的第几天,程序很简单,直接上代码。 # include <iostream> # include <string> using namespace std; # define OK 1; # define ERROR 0; int IsLeapYear(int Year){ return ((Year%4==0&&Year%100!=0)||Year%400==0); } int Daysof原创 2021-11-11 19:58:44 · 278 阅读 · 0 评论 -
数组求长度
关于数组求长度的问题 这两天备赛复习的时候发现一个很有意思的东西,就是我们用什么办法去求一个数组的长度呢?先看这段代码: # include <iostream> using namespace std; int ArryLength(int Arry[]){ return sizeof(Arry)/sizeof(Arry[0]); } int main(void){ int Arry[10]={1,2,3,4,5,6,7,8,9,10}; cout<<A原创 2021-11-05 09:57:22 · 504 阅读 · 0 评论 -
C++两数之和
给出一组数组,给出一个target值,要求输出i,j使Arry[i]+Arry[j]=target 例如: Arry[5]=[1,2,3,4,5] target=6 output[0,4]、[1,3] 代码如下 # include <iostream> using namespace std; class solution { public: int arry[10]; int target; void Set() { int i; cout<<"Enter 10 n原创 2021-04-30 19:25:07 · 556 阅读 · 1 评论