12 2021 档案
摘要:file1:array.h #pragma once #ifndef _ARRAY_H_#define _ARRAY_H_ const int BLOCK_SIZE = 20;typedef struct { int *array; int size;}Array; Array array_crea
阅读全文
摘要://联和 // union #include<stdio.h> #pragma warning(disable : 4996) typedef union AnEit{ int i; char ch[sizeof(int)];}chI; int main(){ chI chi; int i; chi
阅读全文
摘要://自定义数据类型// typedef #include<stdio.h> #pragma warning(disable : 4996) typedef int Length; //Length 成为int 别名 //用Date 替代 struct Adate typedef struct Ada
阅读全文
摘要://指向结构的指针 #include<stdio.h> #pragma warning(disable : 4996) struct date{ int mounth; int day; int year; }myDay; int main(){ struct date *p = &myDay; (
阅读全文
摘要://结构体类型 // #include<stdio.h> #pragma warning(disable : 4996) struct point{ int x; int y;}; int main(){ struct date { int month; int day; int year; };
阅读全文
摘要://结构体类型 // #include<stdio.h> #pragma warning(disable : 4996) struct point //声明结构类型{ int x; int y;}; int main(){ struct date //声明结构类型 { int month; int
阅读全文
摘要://枚举是一种用户定义的数据类型,他用关键字enum 来声明; //枚举量可以作为值,只能是整数 //实际上是以整数来做内部运算和外部输出的 #include<stdio.h> #pragma warning(disable : 4996) enum color {red =3 ,yellow,gr
阅读全文
摘要://C 语言字符串//是指以0结尾的一串字符。//0和 '\0'是一样的,但是和'0'不同。//0标志字符串的结束,但是不是字符串的一部分。//字符串以数组的形式存在,以数组或指针的形式访问,多数情况下是以指针的形式。//string.h 里有很多处理字符串的函数 #include<stdio.h>
阅读全文
摘要:#include<stdio.h> void f(int *p);void g(int k);int main(){ int i = 9; //读取i的地址 printf("&i = %p\n", &i); f(&i); g(i); return 0; } void f(int *p) { //观察
阅读全文
摘要:// 选择排序// #include<stdio.h> // 找到最大值得idint max(int a[], int len) { int maxid = 0; for (int i = 0; i < len; i++) { if (a[i] > a[maxid]) { maxid = i; }
阅读全文
摘要://前面讲到了线性搜索,但是线性搜索有个缺点,就是碰运气。也就是说线性搜索从数组开始位置0开始,直至收到所需要的数据,若果数据成百上千,甚至上万数据,这是很耗费时间的。 // 二分搜索可以大大的节省时间,效率很高。对于有n个数据的数组来说。所需要的搜索次数为log2n,即,有100条数据,我只需要搜
阅读全文
摘要:#include<stdio.h> int amount[] = { 1,5,10,25,50 };const char *name[] = { "penny","nickel","dime","quarter","half-doller" }; int search(int key, int a[
阅读全文
摘要:#include<stdio.h> int search(int key, int a[], int len){ int ret = -1; int i; for (i = 0; i < len; i++) { if (key == a[i]) { ret = i; break; } } retur
阅读全文
摘要:// 输入数量不确定的【0,9】范围内的整数,统计每一种数字出现的次数,输入-1表示结束// #include<stdio.h> int main(){ //定义数组的大小 const int number = 10; int x; //定义数组 int count[number]; int i;
阅读全文
摘要:#include<stdio.h> int main(){ int x; double sum = 0; int cnt = 0; //用来计数 int number[100]; //数组中可以放100个int scanf_s("%d", &x); while (x != -1) { number[
阅读全文
摘要:#include<stdio.h> int main(){ int x; double sum = 0; int cnt = 0; int number[100]; scanf_s("%d", &x); while (x != -1) { number[cnt] = x; sum += x; cnt
阅读全文
摘要:Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) { ui->setupUi(this); connect(ui->lineEdit1, SIGNAL(returnPressed()), this, SLOT(
阅读全文
摘要:#include<stdio.h> int main(){ int x; x = 123456789; do { int d = x % 10; //取出最右边数字 printf("%d ", d);// 删除最右侧数字 if (x>=10) { printf(" "); } x = x / 10;
阅读全文
摘要:#include<stdio.h> int main(){ int a, b; int min ; scanf_s("%d %d", &a, &b); a > b ? min = b : min = a; int ret = 0; int i; for ( i = 1; i <= min; i++)
阅读全文
摘要:#include<stdio.h> int main(){ int n; int i; double sum = 0.0; int sign = 1; scanf_s("%d", &n); for ( i = 1; i < n; i++) { sum += sign * 1.0 / i; sign
阅读全文
摘要:#include<stdio.h> int main(){ int n; int i; double sum = 0.0; scanf_s("%d", &n); for ( i = 1; i < n; i++) { sum += 1.0 / i; } printf("f(%d) = %f\n", n
阅读全文
摘要:#include<stdio.h> int main(){ int x = 2; int count = 0; //for ( int x = 2; x < 100; x++) while(count <50) { int isPrime = 1; for (int i = 2; i < x; i+
阅读全文
摘要:#include<stdio.h> int main(){ for ( int x = 2; x < 100; x++) { int isPrime = 1; for (int i = 2; i < x; i++) { if (x%i == 0) { isPrime = 0; continue; }
阅读全文
摘要:#include<stdio.h> int main(){ int x; scanf_s("%d", &x); int isPrime = 1; for (int i = 2; i < x; i++) { if (x%i == 0) { isPrime = 0; break; } } if (isP
阅读全文
摘要:#include <iostream>#include<stdio.h>#include<time.h> int main(){ srand(time(0)); int number = rand() % 100 + 1; int count = 0; int a = 0; printf("我已经
阅读全文
摘要:// send_series.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。// #include <iostream>#include <Windows.h>#include <atlstr.h>using namespace std; HANDLE hcom; //全局
阅读全文
摘要://指向指针的指针 int num = 520; int *p = # int **pp = &p; printf("num:%d\n", num); printf("num:%d\n", *p); printf("num:%d\n", **pp); //打印地址进行二重验证 printf(
阅读全文
摘要://指针与二维数组 int array[4][5] = { 0 }; printf("sizeof int: %d\n", sizeof(int)); printf("array: %p\n", array); printf("array + 1 : %p\n",array +1); //上面程式证
阅读全文
摘要://数组指针 //int (*p2)[5] int temp[5] = { 1,2,3,4,5 }; //int *p2 = temp; //用指针直接指向数组的首地址,后面可以直接输出 //int(*p2)[5] = temp; // 用数组指针的时候,要是数组指针指向一个地址,否则报错,如注释部
阅读全文
摘要:一路跌跌撞撞 迷迷茫茫 只想快点进步 提升自己 记录代码路上的点点滴滴 或许我不足够优秀 但是我比昨日优秀
阅读全文
摘要://指针数组 int *p2[5]; //根据优先级的结合方式,先结合p1与[5],即p1[5],故 首先是一个数组 //而前方有一个指针符号 故 是指针数组 // 下标 0 1 2 3 4 // 元素 int* int* int* int* int* //指针数组是一个数组,每个数组元素存放一个指
阅读全文
摘要://指针和数组的区别 char str[] = "I love fishC.com!"; int count = 0; while (*str++ != '\0') // 报错,str 是一个地址,不是可修改的左值 { count++; } printf("一共有%d个字符\n", count);
阅读全文
摘要://指针与数组 char str[120]; printf("please input a string:\n"); scanf_s("%s\n", str); printf("your str is :%p\n", str); printf("your str is :%p\n", &str[0]
阅读全文
摘要://指針的定義 char a = 'f'; int f = 123; char *pa = &a; int *pb = &f; printf("a = %c\n", *pa); printf("f = %d\n", *pb); *pa = 'c'; *pb = 1; printf(" now a =
阅读全文