自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 一个疑问,记录一下。

今天在学习指针的时候遇到了一点问题,想不明白,记录一下。第一段代码#include <stdio.h>void test(int arr[]){ int sz = sizeof(arr); printf("%d\n", sz);}int main(void){ int arr[10] = { 0 }; test(arr); return 0;}输出4第二段代码#include <stdio.h>int m...

2021-08-10 09:36:00 96

原创 明解C语言(中级篇)——第三章习题

练习3-1#include <time.h>#include <stdio.h>#include <stdlib.h>int human; //玩家的手势int comp; //计算机的手势int win_no; //玩家获胜次数int lose_no; //玩家失败次数int draw_no; //平局次数char *hd[] = { "石头","剪刀","布" }; //手势/*---初始处理---*/void initializ

2021-08-07 19:21:53 480

原创 明解C语言中级篇—第三章书本代码

List3—1#include <time.h>#include <stdio.h>#include <stdlib.h>int main(void){ int human; int comp; int retry; int judge; srand(time(NULL)); printf("猜拳游戏开始!!!\n"); do { comp = rand() % 3; //生成0~2之间的随机数,其中0对应石头,1对应剪刀,2对应布

2021-08-06 18:40:22 180

原创 明解C语言(中级篇)—第二章

练习2-1#include <stdio.h>#include <time.h>int sleep(unsigned long x){ clock_t c1 = clock(), c2; do { if ((c2 = clock()) == (clock_t)-1) //在这里要记住“==”优先级高于“=” return 0; } while (1000.0*(c2 - c1) / CLOCKS_PER_SEC < x);

2021-08-02 12:27:33 2318

原创 明解C语言(中级篇)—第一章

练习1-1#include <stdio.h>#include <time.h>#include <stdlib.h>int main(void){ srand(time(NULL)); int i = rand() % 7; printf("%d:", i); if (i == 0) printf("大吉\n"); else if (i == 1) printf("中吉\n"); else if (i == 2) printf(

2021-07-10 15:26:42 577 1

原创 明解C语言(入门篇)第十二章

练习12-1#include <stdio.h>#define NAME_LEN 64struct student { char name[NAME_LEN]; int height; float weight; double schlors;};int main(void){ struct student takao = { "Takao",173,86.3 }; printf("姓名是%s,其地址为%p\n", takao.name,&(takao.

2021-05-31 10:10:11 323

原创 明解C语言(入门篇)第十一章

练习11-1#include<stdio.h>int main(void){ char *p = "123"; printf("p=\"%s\"\n", *p); p = "456" +1; printf("p=\"%s\"\n", *p); return 0;}练习11-2

2021-05-30 12:27:28 772 1

原创 明解C语言(入门篇)第十章

练习10-1#include <stdio.h>void adjust_point(int *i){ if (*i < 0) *i = 0; else if (*i > 100) *i = 100;}int main(void){ int num; printf("请输入一个整数:"); scanf_s("%d", &num); adjust_point(&num); printf("经过改动后,该整数变为:%d\n",

2021-05-28 23:05:38 462

原创 明解C语言(入门篇)第九章—代码清单9-9的一些思考

今天在看书时,对于《明解C语言(入门篇)》第三版中的代码清单9-9产生了疑问。代码如下:/* 遍历字符串显示*/#include <stdio.h>/*---显示字符串s(不换行)---*/void put_string(const char s[]){ int i = 0; while (s[i]) putchar(s[i++]);}int main(void){ char str[128]; printf("请输入字符串:"); scanf_s(

2021-05-27 15:15:31 187

原创 明解C语言(基础篇)—第九章

练习9-1:显示{字符串"ABC"}#include <stdio.h>int main(void){ char str[] = "ABC\0DEF"; printf("字符串\"%s\"\n", str); return 0;}

2021-05-27 12:35:57 701

原创 明解C语言(基础篇)—第八章

练习8-1#include <stdio.h>#define diff(x,y) (x-y)int main(void){ int x, y; printf("请输入整数1:"); scanf_s("%d", &x); printf("请输入整数2:"); scanf_s("%d", &y); printf("两者之差为%d。\n", diff(x, y)); return 0;}练习8-2#include <stdi.

2021-05-25 22:17:30 507 1

原创 明解C语言(基础篇)—第七章

练习7-1#include <stdio.h>int main(void){ int n; printf("sizeof 1 =%u\n", sizeof 1); //1是int型,该类型的长度是4 printf("sizeof +1 =%u\n", sizeof + 1); //+1是int型,该类型的长度是4 printf("sizeof -1 =%u\n", sizeof - 1);

2021-05-21 11:46:34 994 1

原创 明解C语言(基础篇)—第6章

练习6-1#include <stdio.h>/*返还两个整数中较小的那一个*/int min2(int a, int b) { return (a < b ? a : b;)}int main(void){ int i, j; puts("请输入两个整数"); printf("整数1:"); scanf_s("%d", &i); printf("整数2:"); scanf_s("%d", &j); printf("两整

2021-05-18 21:04:46 536

原创 明解C语言(基础篇)—第5章部分答案

我在做到练习5-10的时候才想起来可以将代码上传,之前的练习题稍后有机会温书的时候再上传吧。练习5-10#include <stdio.h>int main(void){ int i, j; int m, n; int a[4][3] = { 0 }, b[3][4] = { 0 }; int c[4][4] = { 0 }; /*输入矩阵a*/ puts("输入矩阵a。"); for (i = 0; i < 4; i++) { for (j = 0; .

2021-05-14 10:57:03 617

空空如也

空空如也

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

TA关注的人

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