# C语言基础

# 基础数据类型

#include <stdio.h>
int main(){
//定义数字
int a = 1;
printf("%d",a);

//定义字符
char b = 'a';

//定义字符串
char str[] = "hello";

//定义浮点数
float c = 1.2;

//定义双精度浮点数
double d = 1.3;

//定义布尔值
bool e = true;

return 0;
}
</stdio.h>

# 引用数据类型

#include <stdio.h>
int main(){
//定义数组
//声明一个可以存储10个整数的数组
int arr[10];

//定义时初始化数组
int arr1[5]={1,2,3,4,5}

//定义二维数组
int arr2[2][3]={{1,2,3},{4,5,6}};
}
</stdio.h>

# 函数

结构

返回值 函数名(参数类型 参数名){
函数体
}
#include <stdio.h>

int add(int a,int b){
return a+b;
}
</stdio.h>
上次更新: 10/11/2024, 8:28:36 PM