博文
8月30日(2006-08-31 00:36:00)
摘要:函数循环调用多级调用递归调用 没理解好
数组一维数组二维数组 多维数组
数值数组 只能逐个赋值 int a[5]={1,2,3,4,5};字符数组 可整体赋值 char c[]="C languag"; 数组字符操作函数 1,puts 输出数组字符串 puts(c); 2,gets 读入字符串到数组 gets(c); 3, strcat 连接字符串数组 strcat(c,c1); 4, strcpy 复制字符串数组 覆盖操作 strcat(c,c1); 5, strcmp 比较字符串数组 strcmp(c,c1); 字符串1=字符串2,返回值=0; 字符串1〉字符串2,返回值〉0; 字符串1〈字符串2,返回值〈0; 6, srtlne 获得实际字符串数组长度 l=strlne(c);......
8月28日(2006-08-28 22:14:00)
摘要:变量类型auto static register extern
auto为缺省类型 调用auto变量为其分配内存,调用结束,释放内存static静态存储 变量值在编译时既为其分配内存,程序结束时方释放内存register寄存器存储 变量值存在CPU内部,加快程序运行速度extern外部变量 调用其他源文件内的全局变量 在本源文件内使用
全局变量皆为static类型 用static关键字限定的全局变量,只在定义其的源文件内有效没有被static关键字限定的全局变量,可以在别的源文件先用 extern声明,然后使用
局部变量和全局变量同名,局部变量在运行时将屏蔽全局变量......
8月24日(2006-08-25 00:45:00)
摘要:不带else的if语句是特例
else与最近的if匹配
if else 语句可执行花括号内的复合语句
while, do while, for三个循环语句最强大的是for,也是最容易理解错的。
while (条件) S表达式: 条件为真,执行表达式,条件为假,while循环结束。
do S表达式 while(条件): 先执行表达式,再重复while语句的步骤。
for(表达式1,表达式2,S表达式3):表1赋初值,表2设循环条件,S表3表达式
S表达式多为循环增量,返回给条件式,为真,再执行循环。
三个循序语句可互相嵌套,大部分情况下可互相改写。......
8月23日(2006-08-24 00:05:00)
摘要:getch
getche 输入字符屏幕可见,回车确认字符输入
getchar 输入字符屏幕不可见,无需回车确认
scanf 数据输入格式控制;
数据类型匹配(%d%c,2,a)
数据风格匹配(%d%d,22)
数据长度(%2d%d,223)
数据隐式(%d %d,2 2)
数据显式(%d : %d, 2 : 2)
getchar
putchar 单引号内单个字符的输入输出
scanf
printf 双引号内任意数据的输入输出......
8月22日(2006-08-23 01:23:00)
摘要:void hello()
{
printf("hello,world! \n");
}
main()
{
hello();
}
调用函数输出语名。
分析是否闺年的代码:
main(){ int year; printf("input a year number\n"); scanf("%d",&year); if ( (year % 4 == 0 && year % 100 != 0) || year % 400 == 0 ) printf( "%d is a leap year\n", year ); else printf("%d is not a leap year\n", year ); return year;}
下边在的代码在TC 3.1中提示:Bad command or file name
main(){ int a,b; printf("input two numbers\n"); scanf("%d %d",&a,&b); if(a>b) printf(" %d is thd max \n",a); else printf(" %d is thd max \n",b);}......
函数功能的实现(2006-08-19 01:41:00)
摘要:程序的功能是调用各个函数来实现的,函数的实现机理并不对外公开,函数的概念容易理解,但函数内部的运作机制却很难看明白。
刚刚看到了一个编写乘幂函数的范例,却没看明白函数是如何实现任意数的“乘幂”的
#include <stdio.h>
int power(int m, int n);
main(){ int i; for(i=0; i>10;++i) print("%d %d %d\n" ,i, power(2,i), power(-3,i)); return 0;}
int power(int base, int n){ int i, p; p=1; for(i=1; i<=n; ++i) p=p*base; return p;}......
