- 博客(8)
- 收藏
- 关注
原创 数组
数组 类型 数组名【整型常量】 int ar[ 5 ] = {}; [ ] 内必须是 大于0的整数常量表达式 //C99中 [ ] 内可以是变量 int ar[5] = { 1, 2, 3, 4, 5}; printf(" %d " ,sizeof( ar)); 输出结果为 20; char br[6] = {“hello”}; printf(" %d " ,sizeof( br )); 输出结果为 6 ; int ar[] = {1,2,3}; int n; n = sizeof(ar)/si
2020-06-13 20:47:10
214
原创 strlen() sizeof()
int main() { int ar[5]={1,2,3,4,5}; char str1[10]={“hello”}; char str2[10]={‘h’,‘e’,‘l’,‘l’,‘o’}; char str3[]={“hello”}; char str4[]={‘h’,‘e’,‘l’,‘l’,‘o’}; return 0; } 因为 str1[10]={“hello”} str1[0] = ‘h’ str1[1] = ‘e’ str1[2] = ‘l’ str1[3] = ‘l’ str1[4
2020-06-12 13:23:47
128
原创 2020-06-03
break只能在switch/循环语句中使用 continue:结束本次循环 在while中跳转到判断 在for中 跳转到语句3
2020-06-03 17:32:01
122
原创 2020-06-03
逗号表达式 scanf(“%d”,&n); while(n!=0) { sum+=n; scanf(“%d”,&n); } 可以改写为 while(scanf(“%d”,&n),n!=0) { sum+=n; }
2020-06-03 17:17:45
96
原创 2020-06-03
循环语句 for( ; ; ) 条件可省略 while(1) 每次循环都需要判断 while( x ) x非0⃣️即为真 x不可以省略 如果省略程序报错
2020-06-03 17:09:39
112
原创 2020-06-03
函数 1.函数的声明 例 bool is_leapyear (int year); year 可省略 2.函数的定义 Bool is_leapyear (int year) { } 3.函数的调用 is_leapyear(year)
2020-06-03 17:03:32
121
原创 const
const 一定要要初始化 const int a = 1; int const a = 1; const int a[] = {};
2020-05-31 18:40:06
131
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人