自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Max Consecutive Ones Solution

Given a binary array nums, return the maximum number of consecutive 1’s in the array.Example 1:Input: nums = [1,1,0,1,1,1]Output: 3Explanation: The first two digits or the last three digits are consecutive 1s. The maximum number of consecutive 1s is 3.

2021-04-19 17:07:12 117

原创 C语言 字符串 指针 修改字面量

作者:知乎用户链接:https://www.zhihu.com/question/28191923/answer/40028231来源:知乎C语言标准规定数组的值可以改变,而修改字符串字面量的值的结果是未定义的(详见分割线后,感谢 @Sunchy321 指正)。char s[LEN]和char *s这两个s不是一种东西。这个问题编译器的具体实现一般是这样的:char s[10] = "whatever";也相当于char s[10] = {'w','h','a','t','e','v','e'

2021-04-13 17:46:55 638

原创 C语言:字符串

#include<stdio.h>int main(void){ //字符串字面量太长无法放置在单独一行内的解决办法 printf("Hello\world\n"); printf("Hello" "world"); printf("Hello"); printf("world"); return 0;} 字符串的存储本质上而言,C 语言把字符串字面量作为字符数组来处理。当 C 语言编译器在程序中遇到了长度为 n 的字符串字面量时,它会为字符串字面量分配长度为

2021-04-13 14:35:09 210

原创 C语言:字符串数组与二维字符数组的区别

#include<stdio.h> int main() { char Str1[10] = "Hello"; char Str2[10]; char Str3[10]; char Str4[10]; char Str5[10] = "World"; char* str1[5] = {Str1, Str2, Str3, Str4, Str5}; char str2[5][10] = { "Hello",//注意写逗号 "",

2021-04-12 18:27:23 365

原创 C语言练习:显示一个月的提醒列表

知识点:二维数组;字符串函数此程序会显示每一个月的每日提醒列表。用户需要输入一系列提醒,每条提醒都要有一个前缀来说明是那一个月中的那一天。当用户输入的是 0 而不是有效日期时,程序会显示出录入的全部提醒列表(按日期排序)。下面是会话示例:Enter day and reminder: 24 Suan's birstdayEnter day and reminder: 5 6:00 - Dinner with MargeEnter day and reminder: 7 10:30 - Movie -

2021-04-11 20:37:13 408

原创 逐个字符读取字符串

因为对许多程序而言,scanf 函数和 gets 函数都有风险而且不够灵活,C 程序员经常会自己编写输入函数。通过每次读一个字符的方式读取字符串。如果决定自己设计输入函数,那么需要考虑以下问题:在开始存储字符串之前,函数应该跳过空白字符吗?什么字符导致函数停止读取:换行符,任意空白字符,还是其他某种字符?需要存储这些字符还是忽略掉?如果输入的字符串太长以至于无法存储,那么函数应该忽略额外的字符还是把它们留给下一次输入操作?示例中,我们选择:不跳过空白字符,换行符结束,不存储换行符,忽略掉额外字符。

2021-04-11 20:14:59 8233

原创 C语言指针:找出数组中的最大元素和最小元素

#include <stdio.h>void find(int a[],int length,int *max,int *min);int main(void){ int a[5]; int max, min,i; printf("Enter 5 numbers: "); for(i=0;i<5;i++){ scanf("%d",&a[i]); } find(a,5,&max,&min); printf("Largest numbe

2021-04-11 19:02:15 2748 1

原创 C语言结构体

设有如下定义,则对data中的a成员的正确引用是()。struct sk { int a; float b;}data , *p = & data;A.(*p).data.aB.(*p).aC.p->data.aD.p.data.aanswer:B

2021-03-03 17:20:53 929 2

原创 用一个结构数组记录 5 组时间,请求出这组时间下一秒的时间。

#include<stdio.h>typedef struct time{ int hour; int minute; int second;}; void timeUpdate(struct time*p){ if(p->second!=59) p->second++; else if(p->minute!=59){ p->minute++; p->second=0; }else if(p->hour!=23){ p-

2021-03-03 17:06:01 87 1

原创 C语言 输入今天的日期,显示明天的日期

C语言 输入今天的日期,显示明天的日期//对输入的月份与天数是否正确进行判断//对输入的年份是否是闰年进行判断//对输入的日期是否正好是月末或年末进行判断#include<stdio.h>typedef struct date{ int year; int month; int day;}date;int IsLeapyear(int year){//判断闰年,如果是返回1 if((year%400==0)||(year%4==0&&year%100!

2021-03-02 18:13:53 4248 1

原创 Java判断一个数是否为质数(素数)

质数就是只能被他自身或1整除的数字。质数定义在大于1 的自然数中。2是质数。思路:从2开始遍历i++,到数字本身大小之前停止,每次遍历判断这个数字能否被i整除。如果能被i整除,即num%i==0,则不是质数,返回false,否则返回true。public class PrimeNumber { public static boolean isPrimeNum(int n) { for...

2019-07-04 15:21:51 12662 3

原创 一个线程一次打印5个数,三个线程轮流打印1-75

解法1:package printer1to75;public class Printer1to75 { static class Printer implements Runnable{ private int id; static int num = 1; public Printer(int id) { this.id = id; } @Override...

2019-07-04 13:24:04 475

空空如也

空空如也

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

TA关注的人

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