自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(149)
  • 收藏
  • 关注

原创 链表查找(线性表)

#include<stdio.h>struct node{ node* next; int data;};int main(){ int n,key; while(scanf("%d",&key)!=EOF){ scanf("%d",&n); node* head=new node; ...

2019-11-10 23:29:34 299

原创 sort

直接定义结构体数组然后用sort函数可以AC#include<cstdio>#include<algorithm>using namespace std;const int maxn=1000000;struct stu{ int num; int score;}arr[maxn];bool cmp(stu a,stu b){ r...

2019-11-10 20:47:32 243

原创 括号匹配

#include<iostream>#include<cstdio>#include<stack>#include<string>using namespace std;string str;stack<char> s;bool test(){ for(int i=0;i<str.length();i++...

2019-11-09 00:02:53 163

原创 Day of Week

题意:输出日期对应的星期#include<iostream>#include<string>using namespace std;int getDate(int y,int m,int d){ if(m==1||m==2){ m+=12; y--; } //注意写成()+1,如果不加大括号会错 ...

2019-11-03 16:29:28 138

原创 日期累加

#include<stdio.h>int month[13][2]={ {0,0},{31,31},{28,29},{31,31},{30,30},{31,31},{30,30},{31,31},{31,31},{30,30},{31,31},{30,30},{31,31}};int isLeap(int year){ if((year%400==0)||(yea...

2019-11-03 16:00:40 126

原创 打印日期

#include<stdio.h>int month[13][2]={ {0,0},{31,31},{28,29},{31,31},{30,30},{31,31},{30,30},{31,31},{31,31},{30,30},{31,31},{30,30},{31,31}};int isLeap(int year){ if((year%400==0)||(yea...

2019-11-03 09:20:49 117

原创 沙漏图形

#include<stdio.h>int main(){ int n; while(scanf("%d",&n)!=EOF){ //上面 for(int i=1;i<=n;i++){ for(int j=1;j<=i-1;j++){ printf(" ");...

2019-11-02 23:42:38 248

原创 Hello World for U

#include<stdio.h>#include<string.h>int main(){ int len,side,space; char a[100]; while(scanf("%s",a)!=EOF){ len=strlen(a); side=(len+2)/3; space=le...

2019-11-02 23:12:35 366

原创 查找学生信息

#include<stdio.h>#include<string.h>struct stu{ char num[100]; char name[100]; char sex[20]; int age;}arr[1010];int main(){ char temp[20]; int m; int n; ...

2019-10-31 16:06:51 195

原创 A+B和C

#include<stdio.h>int main(){ int n; long long a,b,c; scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%lld %lld %lld",&a,&b,&c); if(a+b>c){ printf("Case #%d: true...

2019-10-30 23:16:38 194

原创 特殊乘法

#include<stdio.h>#include<string.h>int main(){ int len1,len2,sum; char ch1[11],ch2[11]; while(scanf("%s %s",ch1,ch2)!=EOF){ len1=strlen(ch1); len2=strlen(ch2); ...

2019-10-30 21:47:41 91

原创 A+B

#include<stdio.h>int main(){ char begin1[11],begin2[11]; int i1,j1; int i2,j2; int m,n; while(scanf("%s %s",begin1,begin2)!=EOF){ char last1[11]={'\0'},last2[11]={'\...

2019-10-30 21:33:08 100

原创 剩下的树

#include<stdio.h>#include<string.h>int arr[10010];int main(){ int sum; int L,M; int front,base; while(scanf("%d %d",&L,&M)){ if(L==0&&M==0){ ...

2019-10-30 20:52:32 92

原创 结构体指针

#include<stdio.h>struct student{ int num; char name[10]; int as; int bs; int cs;}arr[5];void input(struct student *p,int len){ int i; for(i=0;i<len;i++){ ...

2019-10-30 09:12:13 90

原创 共用体

#include<stdio.h>#include<stdlib.h>struct { int num; char name[10]; char sex; char job; union{ int class; char position[10]; }category;}arr[100]...

2019-10-30 08:42:50 126

原创 统计得票

#include<stdio.h>#include<string.h>struct person{ char name[20]; int count;}arr[3]={"Li",0,"Zhang",0,"Fun",0};int main(){ int n; scanf("%d",&n); char ch[20]; while(n--){ s...

2019-10-29 23:22:00 146

原创 复制字符串当中的元音字母

要注意的一点是拼接’\0’,#include<stdio.h>#include<string.h>void vowels(char s1[],char s2[]){ int n=0; int len=strlen(s1); for(int i=0;i<len;i++){ if(s1[i]=='a'||s1[i]=='e'||s1[i]=='i'||s...

2019-10-29 12:21:45 184

原创 字符串比较

#include<stdio.h>#include<string.h>int main(){ char ch1[50],ch2[50]; gets(ch1); gets(ch2); int n1=strlen(ch1); int n2=strlen(ch2); int i,j; for(i=0,j=0;i<n1&&j<n2...

2019-10-29 11:47:12 89

原创 解密

主要的思路是利用ASCII码的和的规律#include<stdio.h>#include<string.h>int main(){ char ch[100]; scanf("%s",ch); int n=strlen(ch); for(int i=0;i<n;i++){ if('a'<=ch[i]&&ch[i]<='...

2019-10-29 00:01:29 61

原创 1010 计算两点间的距离

#include<stdio.h>#include<math.h>int main(){ double distance,x1,x2,y1,y2; while(scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2)!=EOF){ distance=sqrt((x1-x2)*(x1-x2)+(y1-y2)...

2019-09-05 19:10:01 155

原创 1009 Sum Problem

#include<stdio.h>int main(){ int n,sum,i; while(scanf("%d",&n)!=EOF){ sum=0; for(int i=1;i<=n;i++){ sum+=i; } printf("%d\n\n",sum); } return 0;}

2019-09-05 19:03:04 107

原创 1008 A+B for Input-Output Practice (VIII)

#include<stdio.h>int main(){ int num,sum,m,n; scanf("%d",&n); while(n--){ sum=0; scanf("%d",&m); while(m--){ scanf("%d",&num); sum+=num; } if(n==0) print...

2019-09-05 18:55:43 183

原创 1007 A+B for Input-Output Practice (VII)

#include<stdio.h>int main(){ int a,b; while(scanf("%d%d",&a,&b)!=EOF){ printf("%d\n\n",a+b); } return 0;}

2019-09-05 18:37:17 136

原创 1006 A+B for Input-Output Practice (VI)

#include<stdio.h>int main(){ int sum,num,n; while(scanf("%d",&n)!=EOF){ sum=0; while(n--){ scanf("%d",&num); sum+=num; } printf("%d\n",sum); } return 0;}

2019-09-05 18:31:46 209

原创 1005 A+B for Input-Output Practice (V)

#include<stdio.h>int main(){ int sum,num,n,m; scanf("%d",&n); while(n--){ sum=0; scanf("%d",&m); while(m--){ scanf("%d",&num); sum+=num; } printf("%d\n",sum);...

2019-09-05 18:14:22 233

原创 1004 A+B for Input-Output Practice (IV)

#include<stdio.h>int main(){ int sum,num,n; while(scanf("%d",&n)){ if(n==0) break; sum=0; while(n--){ scanf("%d",&num); sum+=num; } printf("%d\n",sum); } r...

2019-09-05 18:09:28 232

原创 1003 A+B for Input-Output Practice (III)

#include<stdio.h>int main(){ int a; int b; while(scanf("%d%d",&a,&b)){ if(a==0&&b==0) break; printf("%d\n",a+b); } return 0;}

2019-09-05 17:59:06 182

原创 1002 A+B for Input-Output Practice (II)

#include<stdio.h>int main(){ int n; int a; int b; scanf("%d",&n); while(n--){ scanf("%d%d",&a,&b); printf("%d\n",a+b); } return 0;}

2019-09-05 17:54:00 190

原创 1001 A+B for Input-Output Practice (I)

#include<stdio.h>int main(){ int a; int b; while((scanf("%d%d",&a,&b))!=EOF){ printf("%d\n",a+b); } return 0;}

2019-09-05 17:48:57 199

原创 Stream的终止操作:收集

public class test { //收集 @Test public void test1(){ //collect(Collector c),Collector是收集人的意思,将流转化为其他形式 //Collector接口中方法的实现决定了如何对流执行收集的操作(如收集到List,Set,Map) //Collect...

2019-08-26 17:51:28 372

原创 Stream的终止操作2:规约

public class test { //规约 @Test public void test1(){ //reduce(T iden, BinaryOperator b)可以将流中元素反复结合起来,得到一个值。返回T //参数1是初始值 //例子:计算1-10的自然数的和 List<Integer&g...

2019-08-26 17:33:13 92

原创 Stream的终止操作1:匹配与查找

public class test { //匹配与查找 @Test public void test1(){ List<Employee> employees = EmployeeData.getEmployees(); //allMatch(Predicate p) 检查是否匹配所有元素,所有的都是true结果才为true...

2019-08-26 17:06:53 237

原创 Stream的中间操作

1)筛选与切片public class EmployeeData { public static List<Employee> getEmployees(){ List<Employee> list = new ArrayList<>(); list.add(new Employee(1001, "马化腾", 34, 6000.38));...

2019-08-26 16:18:34 511

原创 Stream概述以及创建Stream对象

用来操作容器中的数据,例如过滤,映射,规约,排序,查找记录等等Stream是和CPU打交道集合关注的是数据的存储,是和内存打交道总结:集合说的是数据,Stream说的是计算注意:①Stream 自己不会存储元素(数据),数据仍然是在集合当中。类似于迭代器,迭代器是用来遍历集合的,迭代器本身也不存数据,数据还是在集合当中。Stream关注的是对数据的运算②Stream 不会改变源对象。相...

2019-08-26 13:20:36 1632

原创 构造器引用与数组引用

和方法引用类似,就是去关注匹配的情况构造器引用:函数式接口的抽象方法的形参列表和构造器的形参列表一致,抽象方法的返回值类型即为构造器所属类的类型public class Employee { private int id; private String name; private int age; private double salary; public int getId()...

2019-08-25 08:33:31 270

原创 方法引用

方法引用的使用情景:当要传递给Lambda体的操作,已经有实现的方法了,可以使用方法引用方法引用本质上是Lambda表达式,所以方法引用作为函数式接口实例使用格式:类(或对象)::方法名(不用写参数列表)类(或对象)相当于就是调用者比如accept方法用println方法去做替换,而println的调用者就是System.out返回的打印流的对象具体分为如下三种情况:1)对象::非...

2019-08-24 23:25:22 90

原创 函数式接口

背景:Lambda表达式针对的都是接口,相当于是给接口提供具体的实现类的对象时使用Lambda表达式,且这个接口中只能有一个抽象方法Lambda表达式的本质是作为接口的实例,准确的说是作为函数式接口的实例函数式接口:只包含一个抽象方法的接口可以通过 Lambda 表达式来创建该接口的对象。(若Lambda表达式抛出一个受检异常(即:非运行时异常),那么该异常需要在目标接口的抽象方法上进行声...

2019-08-24 21:47:45 74

原创 单例模式的懒汉式的线程安全版本

使用同步机制将单例模式中的懒汉式改写为线程安全的public class BankTest {}class Bank{ private Bank(){ } private static Bank instance=null; public static Bank getInstance(){ if(instance==null){...

2019-08-18 23:56:14 112

原创 接口新特性

JDK7及以前,接口中只能定义全局常量和抽象方法全局常量:用public static final修饰,但是书写时可以省略不写抽象方法:用public abstract修饰,但是书写时可以省略不写JDK8,除了定义全局常量和抽象方法以外,还可以定义静态方法和默认方法(用default进行修饰),在接口中可以有方法体了且可以省略掉修饰静态方法和默认方法的public,这个时候是省略,而不是说...

2019-08-18 23:34:54 85

原创 可变参数

问题引入:写int数据求和:两个int进行求和要写一个方法,三个int进行求和要写一个方法,……太麻烦了有没有一个方法可以实现求任意个数据的和呢可变参数:又称参数个数可变,用作方法的形参出现,那么方法参数个数就是可变的了格式:修饰符 返回值类型 方法名(数据类型… 变量名){ }例子:public static int sum(int… a){}public class Fie...

2019-08-18 23:22:05 238

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除