本帖最后由 戒惜舍得 于 2014-5-20 17:24 编辑
- #include <stdio.h>
- void paiXu(int **point, int GeShu);
- int main()
- {
- int num[100], n = 0;
- while ( n<= 0)
- {
- printf("请输入正整数n的值\n");
- scanf("%d", &n);
- }
- printf("请输入%d个数,每输入一个数按下回车\n", n);
- for (int i = 0; i<n; i++)
- {
- scanf("%d",&num[i]);
- }
- int *p = num;
- int **pp = &p;
- paiXu(pp,n);
- printf("%d个数从大到小排序为:\n", n);
- for(int i=0;i<n;i++)
- {
- printf("%d ",(*pp)[i]);
- }
- printf("\n");
- return 0;
- }
- void paiXu(int **point, int GeShu)
- {
- int temp;
- for(int i=0;i<GeShu-1;i++)
- {
- for(int j=0;j<GeShu-1-i;j++)
- {
- if((*point)[j]<(*point)[j+1])
- {
- temp = (*point)[j];
- (*point)[j] = (*point)[j+1];
- (*point)[j+1] = temp;
- }
- }
- }
- }
复制代码
楼主上线了 请回复
|