05 2020 档案
摘要:#include <stdio.h> #include <stdbool.h> #include <stdlib.h> //exit 函数需要 typedef struct arr { char* arr_name; int len; //当前数组长度 int maxlen; }*PARR,ARR;
阅读全文
摘要:#include <stdio.h> #include <stdbool.h> #include <string.h> struct arr //定义结构体类型 { char* arr_name; int len; int maxlen; }; main() { struct arr array1
阅读全文
摘要:#include <stdio.h> void fun(int** q); void fun2(int** q); main() { int* p; //把p的二级指针传给fun fun(&p); printf("%d", *p); //动态分配内存 fun2(&p); } // void fun(
阅读全文
摘要:/*结构体基本练习 */ #include <stdio.h> #include<stdbool.h> #define MALE 0 //男 0 #define FEMALE 1 //女 1 #define MAXNAME 30 //名字数组最多字符数 #define MAXFR 10 //结构体数
阅读全文
摘要:/* 该程序练习二维数组 用户输入3组数,每组5个, (3行5列数组) 计算每组平均值 计算每行平均值 计算所有数的平均值 找出所有数的最大值 可以使用如下数组测试 a[3][5] = {{11,12,13,14,15}, {21,22,23,24,15}, {31,32,33,34,35}}; 想
阅读全文
摘要://数组倒叙排列 #include<stdio.h> #define SIZE 5 void dao(int*, int size); main() { int a[SIZE]; int i; for (i = 0;i < SIZE;i++) { scanf_s("%d", &a[i]); } da
阅读全文
摘要:// #include <stdio.h> int get_input(void); int fac(int); int fac2(int); main() { int input; int ans; int ans2; printf("This progame calculates factori
阅读全文
摘要:// 计算a 和b 之间整数的平方和 // 模块化,主程序做流程控制,1个计算函数,1个输入合法函数,1个范围检测函数 #include <stdio.h> #include<stdbool.h> double sum_square(long a, long b); bool bad_limit(l
阅读全文
摘要://习题1: 打印a -z #include <stdio.h> main() { int ch[26]; char c; int i; for (i = 0, c = 'a';c <= 'z';c++, i++) // ch[i] = c; for (i = 0;i < 26;i++) // pr
阅读全文
摘要://code:1main() { char ch; scanf_s("%c", &ch); while (ch != 'g') { printf("%c", ch); scanf_s("%c", &ch); } } scanf() 依次读入缓存中的数据,并打印,直到 g code 2: main()
阅读全文
摘要:// 循环 do while , 利用数组存放输入的数计算平均值 #include <stdio.h> #define N 10 //使用N 常量 main() { int a[10]; float sum = 0.0; float av; int i = 0; do { printf("Input
阅读全文
摘要:// 打印A-J 5行 // c语言按行打印,内循环打印行的每个字符,外循环打印第2 3 4 5 行 #include <stdio.h> #define ROWS 5 #define CHARS 10 main() { int row; char ch; for (row = 0;row < RO
阅读全文
摘要:1 循环选择 1 do while 出口判断条件是否满足,后面有 “ ;” 至少循环一次 先执行,再判断 如用于先输入 再判断时 for 用于 有初始值,有更新, 循环次数明确,循环计数 while 用于其他 2 i++ 和++i , do while 和 while 区别 // i++ 和++i
阅读全文
摘要:// 计算 1/2+1/4+1/8+ ..... #include <stdio.h> main() { float n; float sum=0.0; float pow_2=1.0; //需要专门用个变量放分母,因为分母要不断*2 for (n = 1;n <= 10;n++) { pow_2
阅读全文
摘要:// 打印小写字母的ASCII //可以看出,97 以字符输出就是 a , 在内存中都是2进制,取决于如何看待 // a +1 就是 b #include <stdio.h> main() { char ch; for (ch = 'a';ch <= 'z';ch++) printf("%c ASC
阅读全文
摘要://函数参数为指针 //修改“主”函数的值 // 在把 s 的地址传递给add(),完成计算,mai()中s 已经被修改 #include <stdio.h> void add(int, int, int*); main() { int a = 2; int b = 10; int s; add(a
阅读全文
摘要:// while循环, 输入int 判断 #include <stdio.h> main() { int num; int sum = 0; int status; status = scanf_s("%d", &num); //如果不是输入int,scanf返回0,如果输入int返回1 while
阅读全文
摘要://找出数组中最大值,数组和指针的关系 #include <stdio.h> int max( int *, int ); main() { int Largest; int a[5] = { 1,3,4,11,2 }; int* pa = a; //a本身就是地址;不能用&a ,是二次指针 //p
阅读全文
摘要:1 // 简单函数调用 2 3 #include <stdio.h> 4 5 void fun(int i); //函数原型声明,编译时告诉编译器形参为int 6 7 main() { 8 int i = 4; 9 char ch = 'A'; 10 11 //printf("%d\n", ch);
阅读全文

浙公网安备 33010602011771号