自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 C PRIMER PLUS 第16章 第7题

#include<stdio.h>#include<stdlib.h>#include<stdarg.h>void show_array(const double ar[], int n);double* new_d_array(int n, ...);int main(void){ double* p1; double* p2; p1 = new_d_array(5, 1.2, 2.3, 3.4, 4.5, 5.6); p2 ...

2021-07-09 10:22:12 96

原创 C PRIMER PLUS 第16章 第6题

#include<stdio.h>#include<stdlib.h>#include<string.h>#define NAMEL 40#define MEMBERS 10struct names { char first[NAMEL]; char last[NAMEL];};int compare(const void*p1,const void*p2);int main(void){ struct names staff[M...

2021-07-09 09:53:11 75

原创 C PRIMER PLUS 第16章 第5题

#include<stdio.h>#include<time.h>#include<stdlib.h>#define SIZE 100void draw(int source[], int size, int amount);int main(void){ int source[SIZE],i,amount; for (i = 0; i < SIZE; i++) source[i] = i+1; while (1)...

2021-07-08 18:21:23 87

原创 C PRIMER PLUS 第16章 第4题

#include<stdio.h>#include<time.h>void timef(double);int main(void){ double delay; clock_t a=clock(); timef(1000000000); clock_t b=clock(); delay = (double)(b - a) / CLOCKS_PER_SEC; printf("%.2f",delay); return 0;...

2021-07-08 17:36:11 62

原创 C PRIMER PLUS 第16章 第3题

#include<stdio.h>#include<math.h>#define DEG_TO_RAD (4*atan(1))/180struct polar { double r; double deg;};struct rectangle { double x; double y;};struct rectangle pol_to_rec(struct polar);int main(void){ struct polar...

2021-07-08 17:19:50 75

原创 C PRIMER PLUS 第16章 第2题

#include<stdio.h>#define MACRO(X,Y) (1.0/(((1.0/(X))+(1.0/(Y)))/2.0))int main(void){ printf("%.2f", MACRO(3, 4)); return 0;}

2021-07-08 15:47:41 52

原创 C PRIMER PLUS 第15章 第6题

#include<stdio.h>struct font { unsigned int id : 8; unsigned int size : 7; unsigned int bold : 1; unsigned int align : 2; unsigned int italic : 1; unsigned int underline : 1;};const char *alignment[3] = { "left","center","r...

2021-07-07 10:42:11 69

原创 C PRIMER PLUS 第15章 第5题

#include<stdio.h>#include<limits.h>unsigned int rotate_l(unsigned int, unsigned int);int main(void){ while (1) { unsigned int input, times; printf("输入要旋转的无符号整数和旋转的次数(以空格隔开):"); scanf("%u%u", &input, &...

2021-07-07 00:57:55 56

原创 C PRIMER PLUS 第15章 第4题

#include<stdio.h>#include<limits.h>int main(void){ int input, bit,i; char save[CHAR_BIT * sizeof(int)+1]; while(1) { printf("输入一个整数作为参数:"); scanf_s("%d", &input); printf("输入指定位的位置(从0开始):"); ...

2021-07-06 22:56:43 63

原创 C PRIMER PLUS 第15章 第3题

#include<stdio.h>#include<limits.h>int open_bit_count(int);int main(void){ int input; printf("输入一个整数"); scanf("%d", &input); printf("\n%d中打开的位有%d个", input, open_bit_count(input)); return 0;}int open_bit_count(int n...

2021-07-06 22:22:02 39

原创 C PRIMER PLUS 第15章 第2题

#include<stdio.h>#include<string.h>#define LENGTH 9int func(char*);char* s_gets(char* st, int n);void itobs(int, char*);void show_bstr(const char*);int main(void){ while (1) { char word1[LENGTH]; char word2[LENG...

2021-07-06 20:57:03 62

原创 C PRIMER PLUS 第15章 第1题

#include<stdio.h>#include<string.h>int func(char*);#define TEST "00011001"int main(void){ char* pbin = TEST; printf("%d",func(pbin)); return 0;}int func(char*pbin)//1101 0010{ float pow = 0.5; int sum=0; for (int...

2021-07-06 17:28:50 45

原创 C PRIMER PLUS 第14章 第11题

#include<stdio.h>#include<math.h>#define SIZE 100double add(double);double multiply(double);void transform(double source[], double target[],int n,double(*pf)(double));int main(void){ double source[SIZE], target[SIZE]; double(*pf)...

2021-07-05 23:53:10 89

原创 C PRIMER PLUS 第14章 第10题

#include<stdio.h>#define DRIVER 3void driver1(void);void driver2(void);void driver3(void);int main(void){ char ch; void(*ptf[DRIVER])(void); printf("Input a,b or c to test the program"); scanf("%c", &ch); while (getchar(...

2021-07-05 23:32:44 97

原创 C PRIMER PLUS 第14章 第9题

#include<stdio.h>#include<string.h>#define NAMEL 21#define SEATS 12struct giant { int seat_number; _Bool is_ordered; char fname[NAMEL]; char lname[NAMEL];};void showmenu(void);void eatline(void);char* s_gets(char* st, in...

2021-07-05 23:18:20 87

原创 C PRIMER PLUS 第14章 第8题

#include<stdio.h>#include<string.h>#define NAMEL 21#define SEATS 12struct giant { int seat_number; _Bool is_ordered; char fname[NAMEL]; char lname[NAMEL];};void showmenu(void);void eatline(void);char* s_gets(char* st, in...

2021-07-05 19:39:15 131

原创 C PRIMER PLUS 第14章 第7题

#include<stdio.h>#include<stdlib.h>#include<string.h>#define MAXTITL 40#define MAXAUTL 40#define MAXBKS 10char* s_gets(char* st, int n);struct book { char title[MAXTITL]; char author[MAXAUTL]; float value; _Bool is_...

2021-07-05 14:01:29 82

原创 C PRIMER PLUS 第14章 第6题

#include<stdio.h>#include<string.h>#define NAMEL 21#define MEMBER 19struct baseball { int number; char fname[NAMEL]; char lname[NAMEL]; int GP; int HITS; int BASE; int RBI; float BABIP;};int main(void){...

2021-07-04 16:46:32 61

原创 C PRIMER PLUS 第14章 第5题

#include<stdio.h>#include<string.h>#define NAMEL 21#define CSIZE 4char* s_gets(char* st, int n);struct name { char fname[NAMEL]; char lname[NAMEL];};struct student { struct name member; float grade[3]; float average;...

2021-07-04 14:20:41 136

原创 C PRIMER PLUS 第14章 第4题

#include<stdio.h>#define FNAME 21#define MNAME 21#define LNAME 21#define SIZE 5struct social { int security_number; struct { char fname[FNAME]; char mname[MNAME]; char lname[LNAME]; };};void func(struct social[], int );void func2(stru...

2021-07-04 13:43:12 123

原创 C PRIMER PLUS 第14章 第3题

#include<stdio.h>#include<string.h>char* s_gets(char*, int);#define MAXTITL 40#define MAXAUTL 40#define MAXBKS 100struct book { char title[MAXTITL]; char author[MAXAUTL]; float value;};int main(void){ struct book librar...

2021-07-04 11:50:13 74

原创 C PRIMER PLUS 第14章 第2题

#include<stdio.h>#include<string.h>struct month { char month_name[10]; char month_abbr[4]; int days; int number;};void func(struct month*);int main(void){ struct month months[12] = { {"January","Jan",31,1}, ...

2021-07-04 04:06:21 58

原创 C PRIMER PLUS 第14章 第1题

#include<stdio.h>#include<string.h>struct month { char month_name[10]; char month_abbr[4]; int days; int number;};void func(struct month*);int main(void){ struct month months[12] = { {"January","Jan",31,1}, ...

2021-07-04 01:54:05 116

原创 C PRIMER PLUS 第13章 第14题

#include<stdio.h>#include<stdlib.h>#define LIN 20#define COL 30int main(void){ int picture[LIN][COL]; FILE *file_in,*file_out; int i, j; if ((file_in = fopen("1.txt", "r")) == NULL) { printf("输入文件打开失败,请重试"); ...

2021-07-01 15:15:51 73

原创 C PRIMER PLUS 第13章 第12题

#include<stdio.h>#include<stdlib.h>#define LIN 20#define COL 30int main(void){ int picture[LIN][COL]; FILE *file_in,*file_out; if ((file_in = fopen("1.txt", "r")) == NULL) { printf("输入文件打开失败,请重试"); exit(EXIT...

2021-07-01 14:34:53 112

原创 C PRIMER PLUS 第13章 第11题

#include<stdio.h>#include<stdlib.h>#include<string.h>#define BUF 256int main(int argc, char* argv[]){ FILE* fp; char buffer[BUF]; if ((fp = fopen(argv[2], "r")) == NULL) { printf("打开文件失败,请重试"); exit(EX...

2021-07-01 13:45:05 42

原创 C PRIMER PLUS 第13章 第10题

#include<stdio.h>#include<stdlib.h>#define NAMEL 41#define BUF 256int main(void){ char file_name[NAMEL]; FILE* fp; char buffer[BUF]; long position; long file_length; printf("输入要打开的文件名"); scanf("%s",file_name);...

2021-07-01 12:48:52 74

原创 C PRIMER PLUS 第13章 第9题

#include<stdio.h>#include<stdlib.h>#include<string.h>#define MAX 41int main(void){ FILE* fp; char words[MAX]; int count = 0; _Bool in_number=0; long position; long num_count=0; char ch; char temp[MAX];...

2021-07-01 11:11:14 75

原创 C PRIMER PLUS 第13章 第8题

#include<stdio.h>#include<string.h>int main(int argc, char* argv[]){ int i; char ch; int count = 0; FILE* fp; if (argc >= 3) { for (i = 2; i < argc; i++) { if ((fp = fopen(argv[i], "r...

2021-07-01 00:22:40 49

原创 C PRIMER PLUS 第13章 第7题 b小题

#include<stdio.h>#include<stdlib.h>#include<string.h>#define BUF 256int main(void){ char file1[BUF]; char file2[BUF]; FILE *input1,*input2; char temp[BUF]; printf("输入要打开的两个文件的文件名,以空格隔开\n"); while ((scanf("%s%s...

2021-06-30 22:49:32 58

原创 C PRIMER PLUS 第13章 第7题 a小题

#include<stdio.h>#include<stdlib.h>#define BUF 256int main(void){ char file1[BUF]; char file2[BUF]; FILE *input1,*input2; char temp[BUF]; printf("输入要打开的两个文件的文件名,以空格隔开\n"); while ((scanf("%s%s", file1, file2)) != 2)...

2021-06-30 22:30:02 56

原创 C PRIMER PLUS 第13章 第6题

#include<stdio.h>#include<stdlib.h>#include<string.h>#define LEN 40int main(void){ FILE* in, * out; int ch; char name[LEN]; char input_name[LEN]; int count = 0; printf("Enter input file"); scanf_s("%s", in...

2021-06-30 18:24:19 51

原创 C PRIMER PLUS 第13章 第5题

#include<stdio.h>#include<stdlib.h>#include<string.h>#define BUFSIZE 4096#define SLEN 81void append(FILE* source, FILE* dest);char* s_gets(char* st, int n);int main(int argc, char* argv[]){ FILE* fa, * fs; int files = 0;...

2021-06-30 17:40:44 101

原创 C PRIMER PLUS 第13章 第4题

#include<stdio.h>#define BUF 256int main(int argc, char* argv[]){ FILE* fp; char temp[BUF]; for (int i = 1; i <argc; i++) { fp = fopen(argv[i], "r"); while (fgets(temp, BUF, fp)) fputs(temp, stdout);...

2021-06-30 16:52:46 34

原创 C PRIMER PLUS 第13章 第3题

#include<stdio.h>#include<string.h>#include<ctype.h>#define NAMEL 256#define BUF 256int main(void){ FILE* fp; char file_name[NAMEL]; char temp[BUF]; printf("输入文本文件名"); scanf_s("%s",file_name,NAMEL); fp = fope...

2021-06-30 16:23:56 62

原创 C PRIMER PLUS 第13章 第2题

#include<stdio.h>#include<stdlib.h>#define BUF 256int main(int argc, char* argv[]){ FILE* source, * target; char temp[BUF+1]; if (argc != 3) { printf("参数输入错误,请重试"); exit(EXIT_FAILURE); } if ((source ...

2021-06-30 15:52:15 83 2

原创 C PRIMER PLUS 第13章 第1题

#include<stdio.h>#include<stdlib.h>#define SIZE 256int main(void){ int ch; FILE* fp; unsigned long count = 0; char file[SIZE]; printf("请输入要处理的文件名:"); while ((scanf_s("%s", file)) != 1) printf("输入错误,请重试"); ...

2021-06-30 15:26:09 55

原创 C PRIMER PLUS 第13章 随机取数

#include<stdio.h>#include<stdlib.h>#define ARSIZE 1000int main(void){ double numbers[ARSIZE]; double value; const char* file = "numbers.txt"; int i; long pos; FILE* iofile; for (i = 0; i < ARSIZE; i++) ...

2021-06-30 11:54:55 41

原创 C PRIMER PLUS 第13章 添加内容到文件末尾

#include<stdio.h>#include<stdlib.h>#include<string.h>#define BUFSIZE 4096#define SLEN 81void append(FILE* source, FILE* dest);char* s_gets(char*st, int n);int main(void){ FILE* fa, * fs; int files = 0; char file_app[SL...

2021-06-30 11:12:48 58

原创 C PRIMER PLUS 第12章 第9题

#include<stdio.h>#include<stdlib.h>#include<string.h>#define SIZE 46int main(void){ int words,i; char temp[SIZE]=""; printf("How many words do you wish to enter?"); while ((scanf_s("%d", &words)) != 1 || words &lt...

2021-06-29 14:25:41 74

空空如也

空空如也

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

TA关注的人

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