随笔分类 - c/c++
摘要:c语言中函数形参 -- 值传递,址传递,引用传递
阅读全文
摘要:001、函数体内的变量名不可以和形参同名 a、 [root@PC1 test]# ls test.c [root@PC1 test]# cat test.c #include <stdio.h> int max(int a, int b) { int k = 100; return a > b ?
阅读全文
摘要:001、 [root@PC1 test]# ls test.c [root@PC1 test]# cat test.c #include <stdio.h> int max(int a, int b) // 创建一个名为max的函数 { int k = 100; if(a > b) { return
阅读全文
摘要:001、 [root@PC1 test]# ls test.c [root@PC1 test]# cat test.c ##测试c程序 #include <stdio.h> int main(void) { int i,j; i = j = 5; // 连续赋值 printf("i = %d\n",
阅读全文
摘要:001、 [root@PC1 test]# ls test.c [root@PC1 test]# cat test.c ## 测试程序 #include <stdio.h> int main(void) { int var1 = 5; // 初始化一个变量var1 int array1[var1]
阅读全文
摘要:001、一维数组 [root@PC1 test1]# ls test.c [root@PC1 test1]# cat test.c #include <stdio.h> int main(void) { int v1[5] = {3, 4, 8}; printf("length of v1 is %
阅读全文
摘要:001、 [root@PC1 test]# ls test.c [root@PC1 test]# cat test.c #include <stdio.h> int main(void) { double tensu[2][4][3] = {{{3,4,2},{2,4,4},{2,4,3},{1,5
阅读全文
摘要:001、double型数据的输入 [root@PC1 test]# ls test.c [root@PC1 test]# cat test.c ## 测试程序 #include <stdio.h> int main(void) { double vx; printf("vx = "); scanf(
阅读全文
摘要:001、 [root@PC1 test]# ls test.c [root@PC1 test]# cat test.c ## 测试c程序 #include <stdio.h> int main(void) { int i,j,k; int v1[4][3]; int v2[3][4]; int v3
阅读全文
摘要:001、 [root@PC1 test]# ls test.c [root@PC1 test]# cat test.c ## 测试c程序 #include <stdio.h> int main(void) { int i,j; int v[4][3]; for(i = 0; i < 4; i++)
阅读全文
摘要:声明是不赋值; 初始化是给数组元素赋值。 001、 [root@PC1 test]# ls test.c [root@PC1 test]# cat test.c ## 测试c程序 #include <stdio.h> int main(void) { int ay[3]; // 声明,不赋值 int
阅读全文
摘要:01、 [root@PC1 test]# ls test.c [root@PC1 test]# cat test.c ## 测试c程序 #include <stdio.h> int main(void) { int ay[4][3] = {{2,3,8},{1,4,2},{8,7,3},{6,2,3
阅读全文
摘要:001、数组的声明 01、数组的声明包括数组元素的类型,数组元素的类型只能是一种。 02、数组的名称;比如 array1 03、数组的大小(长度) [root@PC1 test]# ls test.c [root@PC1 test]# cat test.c ## 测试c程序 #include <st
阅读全文
摘要:001、不使用对象式宏 [root@localhost test]# ls test.c [root@localhost test]# cat test.c ## 测试程序 #include <stdio.h> int main(void) { int i, sum = 0; int v[5] =
阅读全文
摘要:001、 [root@PC1 test]# ls test.c [root@PC1 test]# cat test.c #include <stdio.h> int main(void) { int i; puts("please input an integer."); printf("i = "
阅读全文
摘要:001、 [root@localhost test]# ls ## 两个测试c程序 test01.c test02.c [root@localhost test]# cat test01.c ## 后置递增运算符,表达式的值等于递增前的表达式的值 #include <stdio.h> int mai
阅读全文
摘要:001、 [root@localhost test]# ls test.c [root@localhost test]# cat test.c #include <stdio.h> int main(void) { int i; printf("i = "); scanf("%d", &i); if
阅读全文
摘要:001、 [root@localhost test]# ls test.c [root@localhost test]# cat test.c #include <stdio.h> int main(void) { int n1,n2; puts("please input two integers
阅读全文
摘要:001、相等运算符 == != 002、关系运算符 > >= < <= 003、条件运算符 a ? b:c [root@localhost test]# ls test.c [root@localhost test]# cat test.c #include <stdio.h> int main(v
阅读全文