自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 c primer plus第十二章编程题1

#include <stdio.h>int critic(int n);int main(viod){ int n;//用非全局变量 printf("How many pound...\n"); scanf_s("%d", &n); while (n != 56) n = critic(n); printf("You must...\n"); return 0;}int critic(int n){ printf("No luck..."); scan.

2022-02-23 16:08:50 343

原创 primer plus第十一章编程题11(列表变动待改进)

#include <stdio.h>#include <stdbool.h>#include <string.h>void c1(char p[][20], int row){ int index = 0; printf("Your original strings are:\n"); while (index < row) { printf("%s\n", p[index]); index++; }}void c2(char p[].

2022-02-08 12:45:02 398

原创 c primer plus第十一章编程题10(待简化)

#include <stdio.h>void reverse(char* line){ int index=0; char temp[20]; char* swi; swi = line; while (*swi) { if (*swi == ' ') { swi++; continue; } else { temp[index] = *swi; swi++; index++; } } temp[index] = '...

2022-01-24 20:54:43 282

原创 c primer plus第十一章编程题9

#include <stdio.h>void reverse(char* line){ int length; int index; char temp; length = strlen(line) - 1; for (index = 0; index < length; length--, index++) { temp = *(line + index); *(line + index) = *(line + length); *(line + lengt.

2022-01-24 14:53:45 274

原创 c primer plus第十一章编程题8

#include<stdio.h>#include<string.h>int string_in(char* a, char* b){ char* temp1; char* temp2; char* conclude = NULL; while (*a) { if (*a == *b) { temp1 = a; temp2 = b; while (*a++ == *b++) { if (*b == '\0') { .

2022-01-11 16:46:25 106

原创 c primer plus第十一章编程题6

#include<stdio.h>#include<string.h>char* find(char* a, char b){ int flag = 0; while (*a) { if (*a == b) { flag = 1; break; } else a++; } return flag;}int main(){ char* c; char e[20]; char d='a'; int n; printf(.

2022-01-11 14:32:54 101

原创 c primer plus第十一章编程题5

#include<stdio.h>#include<string.h>char* find(char* a, char b){ while (*a != b && *a != '\0') { a++; } return *a == b ? a : NULL;}int main(){ char* c = "edcaba"; char d = 'c'; c = find(c, d); puts(c);}

2022-01-11 12:42:09 142

原创 c primer plus第十一章编程题4

#include<stdio.h>char* dgets(char* st, int n){ char a; a = getchar(); while (a != '\n'&& n != 0) { if (a == ' ' || a == '\t') { a = getchar(); continue; } *st = a; st++; n--; a = getchar(); if (a == ' '||a == '\t.

2022-01-03 16:38:31 48

原创 c primer plus第十一章编程题3

#include<stdio.h>char* dgets(char* st){ char a; a = getchar(); while (a != '\n') { if (a == ' ') { a = getchar(); continue; } *st = a; st++; a = getchar(); if (a == ' ') break; } *st = '\0'; return st;}int main().

2022-01-03 16:32:23 315

原创 c primer plus第十一章编程题2

#include<stdio.h>char* dgets(char* st, int n){ char a; a = getchar(); while (a != '\0' && n != 0&& a != ' '&& a != '\n' && a != '\t') { *st = a; st++; n--; a = getchar(); } *st = '\0'; return st;}.

2022-01-03 15:12:54 302

原创 c primer plus第十一章编程题1

#include<stdio.h>char* dgets(char* st, int n){ char a; a = getchar(); while (a != '\0' && n != 0) { *st = a; st++; n--; a = getchar(); } *st = '\0'; return st;}int main(){ char* string[20]; dgets(string, 10); puts(st.

2022-01-03 14:31:37 147

原创 代码储存(字符串处理)

char* s_gets(char* st, int n){ char* ret_val; int i = 0; ret_val = fgets(st, n, stdin); if (ret_val) { while (st[i] != '\n' && st[i] != '\0') i++; if (st[i] == '\n') st[i] = '\0'; else while (getchar() != '\n') continue; .

2021-12-31 15:34:58 163

原创 c primer plus第十章编程题13

#include<stdio.h>void task(int arr[][5], int rows){ int row, column; float sum_row=0, sum_all=0; int max = -65535; for (row = 0; row < rows; row++) { for (column = 0; column < 5; column++) { scanf_s("%d", &arr[row][column]);.

2021-12-14 12:45:27 935

原创 c primer plus第十章编程题12

#include<stdio.h>#define Months 12#define Years 5float sum_y(float arr[][12], int row){ float SumRain=0, RainOfYear; int Y, M; for (Y = 0; Y < row; ++Y) { RainOfYear = 0; for (M = 0; M < Months; ++M) .

2021-12-13 16:55:07 189

原创 c primer plus第十章编程题10

#include <stdio.h>void sum(int* arr1, int* arr2, int* arr3, int* end){ while (arr1 < end) { *arr3 = *arr1 + *arr2; arr1++; arr2++; arr3++; } return;}int main(){ int a[4] = { 2, 4, 5, 8 }; int b[4] = { 1, 0, 4, 6 }; int c[4];.

2021-12-13 16:27:13 73

原创 c primer plus第十章编程题8

#include <stdio.h>void copy_ptr(double* target2, double* source, int number);int main(){ double source[7] = { 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7 }; double target2[3]; copy_ptr(target2, &source[4], 3); printf("%g\n%g", source[6], target2[2].

2021-12-13 14:31:41 68

原创 c primer plus第十章编程题7

#include <stdio.h>void copy_ptrs(double target3[][2], double(* source)[2], int** end1, double* a, double* b, int* end2);int main(){ double source[2][2] = { {1.1, 2.2}, {3.3, 4.4} }; double target3[2][2]; copy_ptrs(target3, source, source+2, *t.

2021-12-13 14:00:20 113

原创 c primer plus第十章编程题6

#include <stdio.h>void largest(double a[], int range);int main(){ double arry[5] = { 4.2, 7.2, 8.3, 10.5, 1.1 }; largest(arry, 5); printf("%g", arry[4]); return 0;}void largest(double a[], int range){ int i,j; double temp; for (i = 0, .

2021-12-13 11:13:03 77

原创 c primer plus编程题第十章5

#include <stdio.h>double largest(double a[], int range);int main(){ double arry[5] = { 4.2, 7.2, 8.3, 10.5, 1.1 }; printf("%g", largest(arry, 5)); return 0;}double largest(double a[], int range){ int i; double max = -3795; double min = .

2021-12-13 11:05:07 183

原创 c primer plus第十章编程题4

#include <stdio.h>int largest(double a[], int range);int main(){ double arry[5] = { 4.2, 7.2, 8.3, 10.5, 1.1 }; printf("%d", largest(arry, 5)); return 0;}int largest(double a[], int range){ int i; int sign = 0; int max = -3795; for (i .

2021-12-13 10:46:25 199

原创 c primer plus第十章编程题3

#include <stdio.h>int largest(int a[], int range);int main(){ int arry[5] = { 4, 7, 8, 10, 1 }; printf("%d", largest(arry, 5)); return 0;}int largest(int a[], int range){ int i; int max = 0; for (i = 0; i < range; i++) { if (a[i] .

2021-12-13 10:39:59 186

原创 c primer plus第十章编程题2

#include <stdio.h>void copy_arr(double target[], double* source, int range);void copy_ptr(double* target2, double* source, int range);void copy_ptrs(double* target3, double* source, int differ);int main(){ double source[5] = { 1.1, 2.2, 3.3, 4.

2021-12-13 09:57:45 589

原创 c primer plus第十章编程题1

把for循环中的:subtot += rain[year][month];都替换成:subtot += *(*(rain+year)+month);就可以了,其他和原版相同

2021-12-09 16:18:35 511

原创 c primer plus第九章编程题10

#include <stdio.h>void to_base_n(int i, int j){ int r = 0; if (i >= j) to_base_n(i / j, j); r = i % j; printf("%d", r); return;}int main(){ int a, b; printf("Please enter numbers and the base(q to quit):"); while (scanf_s("%d %d",.

2021-12-01 16:25:53 628

原创 c primer plus第九章编程题9

#include <stdio.h>double power(double i, int j){ double powers = 1; int index; if (i != 0) if (j > 0) powers = i * power(i, j - 1); else if (j == 0) powers = 1; else powers = (1 / i) * power(i, j + 1); else if (j != 0) p.

2021-12-01 14:06:22 563

原创 c primer plus第九章编程题8

#include <stdio.h>double power(double i, int j){ double powers = 1; int index; if (i != 0) { if (j > 0) for (index = 0; index < j; index++) powers *= i; else if (j == 0) powers = 0; else { i = 1 / i; for (index = .

2021-12-01 10:35:07 622

原创 c primer plus第九章编程题7

#include <stdio.h>int check(char ch){ int sign; if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) { if (islower(ch)) sign = ch - 'a' + 1; else sign = ch - 'A' + 1; } else sign = -1; return sign.

2021-11-30 18:29:42 57

原创 c primer plus第九章编程题4

#include <stdio.h>double harmonic(double a, double b){ return 1 / ((1 / a + 1 / b) / 2);}int main(){ double i, j, k; scanf_s("%lf %lf", &i, &j); k = harmonic(i, j); printf("%g", k); return 0;}

2021-11-30 16:34:12 165

原创 c primer plus第九章编程题6

没有放数组然后用排序算法所以比较长#include <stdio.h>void func(double* a, double * b, double* c){ double max, middle, minum; if (*a > *b) { if (*b > *c) { max = *a; middle = *b; minum = *c; } else if (*c > *a) { max = *c; midd

2021-11-30 10:09:51 78

原创 c primer plus第九章编程题5

#include <stdio.h>void larger_of(double* a, double* b){ double max; max = (*a > *b) ? *a : *b; *a = max; *b = max;}int main(){ double i, j; scanf_s("%lf %lf", &i, &j); larger_of(&i, &j); printf("%g %g", i, j); retur.

2021-11-30 09:57:44 55

原创 c primer plus第九章编程题3

#include <stdio.h>void func(char i, int a, int b){ int index1, index2; for (index1 = 0; index1 < a; index1++) { for (index2 = 0; index2 < b; index2++) printf("%c", i); printf("\n"); }}int main(){ char a = '*'; int i, j; sca.

2021-11-30 09:46:44 58

原创 c primer plus第八章编程题8

#include <stdio.h>#include <string.h> void menu(); float get_number(); void add(float a, float b); void substract(float a, float b); void multiply(float a, float b); void divide(float a, float b); char get_char();.

2021-11-29 16:35:38 101

原创 c primer plus 第九章编程题11

int Fibonacci(int i){ int second, first, sum; if (i < 3) sum = 1; else { for (second = 1, first = 1, sum = 0; i > 2; i--) { sum = second + first; //举例:f(5) = f(4)(大) + f(3)(小) first = second; // f(4) = f(3.

2021-11-25 09:11:47 274

原创 c primer plus第八章编程题6

//需结合main函数使用char get_first(void){ char ch; while ((ch = getchar()) == ' ') continue; while (getchar() != '\n') continue; return ch;}

2021-11-22 15:45:31 299

原创 c primer plus第八章编程题5

#include <stdio.h>int main(){ int initial = 50, downpoint = 0, highpoint = 100; char ch; printf("Please pick a number and don't change it in your mind.\n"); printf("Let me guess, if it is %d or higher or lower than it?\n", initial); printf("I.

2021-11-22 10:23:18 333

原创 c primer plus第八章编程题4

#include <stdio.h>int main(){ int ch; int i = 0, sum = 0; printf("Enter characters:"); while ((ch = getchar()) != EOF) { if (!(islower(ch)||isupper(ch))) continue; while (islower(ch) || isupper(ch)) { sum++; ch = getchar();.

2021-11-21 18:05:56 187

原创 c primer plus第八章编程题3

#include <stdio.h>int main(){ int ch; int lc = 0, uc = 0, ol = 0; printf("Enter characters:"); while ((ch = getchar()) != EOF) { if (islower(ch)) lc++; else if (isupper(ch)) uc++; else ol++; } printf("There are %d lowercase l.

2021-11-21 15:36:13 166

原创 c primer plus第八章编程题2

#include <stdio.h>int main(){ int ch; int i = 0; printf("Start to input characters:"); while ((ch = getchar()) != EOF) { if (ch < 32) if (ch == '\n') printf("\\n(%d) ", ch); else if (ch == '\t') printf("\\t(%d) ", ch); e.

2021-11-21 15:02:42 309

原创 c primer plus第七章编程题11

#include <stdio.h>#define ATCH 2.05#define BT 1.15#define CRT 1.69#define SHIP1 6.5#define SHIP2 14#define WEIGHT1 5#define WEIGHT2 20#define DISCOUNT 0.95#define LIMIT 100void check(int at, int bet, int cart);int main (void){ int atc...

2021-11-21 13:43:15 408

原创 C primer plus第七章编程题8

#include <stdio.h>#include <math.h>#include <string.h>#define OVERTIME 40#define TAXRATE1 0.15#define TAXRATE2 0.2#define TAXRATE3 0.25#define TAXBASE1 300#define TAXBASE2 450#define TAX1 TAXBASE1 * TAXRATE1;#define TAX2 TAXBASE

2021-11-18 13:30:31 260

空空如也

空空如也

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

TA关注的人

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