C 练习实例40

C 语言教程 · 2019-02-21 21:59:10

题目:将一个数组逆序输出。

程序分析:用第一个与最后一个交换。

程序源代码:

实例

// Created by www.codercto.com on 15/11/9. // Copyright © 2015年 码农教程. All rights reserved. // #include<stdio.h> #define N 10 int main() { int a[N]={0,1,2,3,4,5,6,7,8,9}; int i,t; printf("原始数组是:\n"); for(i=0;i<N;i++) printf("%d ",a[i]); for(i=0;i<N/2;i++) { t=a[i]; a[i]=a[N-1-i]; a[N-1-i]=t; } printf("\n排序后的数组:\n"); for(i=0;i<N;i++) printf("%d ",a[i]); printf("\n"); return 0; }

以上实例输出结果为:

原始数组是:
0 1 2 3 4 5 6 7 8 9 
排序后的数组:
9 8 7 6 5 4 3 2 1 0 

点击查看所有 C 语言教程 文章: https://codercto.com/courses/l/17.html

查看所有标签

Making Things See

Making Things See

Greg Borenstein / Make / 2012-2-3 / USD 39.99

Welcome to the Vision Revolution. With Microsoft's Kinect leading the way, you can now use 3D computer vision technology to build digital 3D models of people and objects that you can manipulate with g......一起来看看 《Making Things See》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具