add linear regression details

This commit is contained in:
2025-01-19 17:11:00 +08:00
parent ee2c51ff65
commit 5ea5e3cba1
48 changed files with 1292 additions and 229 deletions

View File

@@ -0,0 +1,81 @@
---
title: C lang
tags: C C++
abbrlink: 12462
date: 2025-01-15 20:41:26
---
### c lang在windows下的开发VS code
[WinLibs - GCC+MinGW-w64 compiler for Windows](https://winlibs.com/#download-release)下载你需要的版本
解压到`D:\ProgramModule`,并将 `bin\`加入环境变量`PATH`
打开新的`Terminal`输入`gcc -v`,查看`gcc`是否安装成功
`VS code` 的插件管理下载`Code Runner``C\C++`这两个插件
`*.c`源文件的内容区,右键点击`Run Code` ,即可运行成功
![](/img/language/c-env-conf.png)
### 数据类型
- 整数类型
```c
    short a = 12;
    int b = 100;
    long c = 1000L;
    long long d = 1000000LL;
    unsigned int e = 10;
    printf("a: %hd\n",a);
    printf("b: %d\n",b);
    printf("c: %ld\n",c);
    printf("d: %lld\n",d);
    printf("e: %u\n",e);
    printf("f: %.3f\n",f);
```
- 小数类型
```c
float f = 3.14F;
printf("f: %.3f\n",f);
double g = 5.65;
printf("g: %.2lf\n",g);
```
- 字符类型
```c
char h = 'x';
printf("x: %c\n",x);
```
### 类型转换
- 隐式转换
- 强制转换
```c
int b = 23;
short c = (short) b;
```
### 数组
```c
#include <stdio.h>
int main(){
    int arr [10] = {2,3,4,5,6,7,8,9,10,11};
    arr[0] = 1525;
    *(arr+1) = 25;
    int len = sizeof(arr)/sizeof(arr[0]);
    void printArr(int arr[], int len){
        for (int i = 0; i < len;i++){
            printf("%d\t",arr[i]);
        }
    }
    printArr(arr,len);
    return 0;
}
```
### 指针
```c
// swap the value of a and b
    void swap(int* x, int* y){
        int temp = *x;
        *x = *y;
        *y = temp;
    }
    int a = 5;
    int b = 10;
    swap(&a, &b);
    printf("a = %d b = %d\n", a, b);
```