C语言中的数组
来源:互联网 发布:软件企业研发费用 编辑:程序博客网 时间:2024/06/06 15:40
1、数组的组成: 类型 变量名 【数字的大小】
2、数组的定义方式:① int a【10】 ; ② int a【】
3、数组的赋值方法:① a [10] = { 1,2,3,4,5,6,7,8,9,10} ; ② a [ ] = {1,2,3,4,5,6,7,8,9,10} ;
③下标赋值:a [ 0 ] = 1 , a [ 1 ] == 2 , a [ 2 ] == 3 等
④循环赋值:for ( int i = 1; i < 11; i ++ ){
a [ i - 1 ] = i;
}
4、在写一个数组时一定要注意数组的边界不能超过数据的边界;
5、下面是几个数组的列题:
逆序输出0-9
void main(){
int _arr[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
for (int i = 0; i < 10; i++){
printf("%d,", _arr[9-i]);
}
getchar();
}
用函数写一个冒泡排序法
void main(){
int t = 0;
int a[] = [1, 2, 3, 4, 5, 6, 7, 8, 9];
for (int i = 0; i < (sizeof(a) / sizeof(int)); i++){
for (int j = 1; j < (sizeof(a) / sizeof(int)); j++){
if (a[j]>a[j - i]){
a[j] = a[j] + a[j - 1];
a[ j - 1] = a[j] - a[j - 1];
a[j] = a[j] - a[j - 1];
}
}
}
while (t<9){
printf("%d", a[9]);
t++;
}
getchar();
}
- C语言中的数组
- C语言中的数组
- C语言中的数组
- C语言中的数组
- c语言中的数组
- C语言中的数组
- C语言中的数组
- C语言中的数组
- C语言中的数组
- 转贴 C语言中的数组
- C语言中的多维数组
- C语言中的数组越界
- C语言中的多维数组
- C语言中的数组排序
- c 语言中的边长数组
- C语言中的数组指针
- C语言中的指针数组
- C语言中的字符数组
- 密码学相关
- js判断是否为微信浏览器【代码】
- TCP状态转换图
- string类中的size()和length()的区别
- **YII** 系列五yii框架的总体理解
- C语言中的数组
- SELECT INTO 和 INSERT INTO SELECT 两种表复制语句
- Android 显示SQLite 表:方法TableLayout
- 棋盘翻转
- Oracel数据库连接时出现:ORA-12518:监听程序无法分发客户机连接
- 删除数据时弹出提示信息
- 敏捷
- andorid开发中遇到的bug
- hibernate 中使用 createQuery(hql).executeUpdate() 更新不成功,并且不报错