第五章 运算符,表达式和语句
2. sizeof的返回值类型是 size_t 类型。size_t类型是一个无符号整数类型。
3. ++i和 i++ -- 一样。
aplus = a++ 使用a 的值之后改变a。(a++)
aplub = ++b 改变b的之后使用b.
第六章 C控制语句:循环
关键字:for while do while。
函数 fabs()
循环中的常用数组。
编写具有返回值的函数。
1. while 和 scanf()的组合使用。while(scant(“%d”,&num)==1)
2. fabs()求一个数或者一个运算式的绝对值。
3. n = -3;
4. while(n)
5. printf("%2d is true." n);
printf("%2d is false." n);
6. 关于判读语句的一些错误写法和一些防止错误写法的小技巧
7.getchar()和putchar()
while((ch = getchar()))
{
if(ch == ' ')
putchar(ch);
else
putchar(ch+1);
}
8. ctype.h 字符判断函数
9.iso646.h文件中 宏定义了 && == and ,|| = or,! = not
11.continue 和break、
对于for循环来说:
int main(int argc, const char * argv[])
{
int i;
for(i = 0 ; i < 10;i++)
{
if(i == 3)
break;
// continue;
printf("%dHello, World!\n",i);
}
return 0;
}
//while
while(i-- > 0)
{
if(i == 3)
// break;
continue;
printf("%dHello, World!\n",i);
}
结果和下面的一样。
break:
0Hello, World!
1Hello, World!
2Hello, World!
continue:
0Hello, World!
1Hello, World!
2Hello, World!
4Hello, World!
5Hello, World!
6Hello, World!
7Hello, World!
8Hello, World!
9Hello, World!
12.
13.swtich的例子。
1. 表达式树。来表示赋值的程序。
2. sizeof的返回值类型是 size_t 类型。size_t类型是一个无符号整数类型。
3. ++i和 i++ -- 一样。
aplus = a++ 使用a 的值之后改变a。(a++)
aplub = ++b 改变b的之后使用b.
第六章 C控制语句:循环
关键字:for while do while。
函数 fabs()
循环中的常用数组。
编写具有返回值的函数。
1. while 和 scanf()的组合使用。while(scant(“%d”,&num)==1)
2. fabs()求一个数或者一个运算式的绝对值。
3. n = -3;
4. while(n)
5. printf("%2d is true." n);
printf("%2d is false." n);
6. 关于判读语句的一些错误写法和一些防止错误写法的小技巧
· 比较和赋值 的区别:
· 如果是这样的话,很巧妙的躲开了少一个=的bug。
7.getchar()和putchar()
while((ch = getchar()))
{
if(ch == ' ')
putchar(ch);
else
putchar(ch+1);
}
8. ctype.h 字符判断函数
9.iso646.h文件中 宏定义了 && == and ,|| = or,! = not
10.
11.continue 和break、
对于for循环来说:
int main(int argc, const char * argv[])
{
int i;
for(i = 0 ; i < 10;i++)
{
if(i == 3)
break;
// continue;
printf("%dHello, World!\n",i);
}
return 0;
}
//while
while(i-- > 0)
{
if(i == 3)
// break;
continue;
printf("%dHello, World!\n",i);
}
结果和下面的一样。
break:
0Hello, World!
1Hello, World!
2Hello, World!
continue:
0Hello, World!
1Hello, World!
2Hello, World!
4Hello, World!
5Hello, World!
6Hello, World!
7Hello, World!
8Hello, World!
9Hello, World!
12.
13.swtich的例子。