注册 登录
悉远 返回首页

焰阳小窝 http://bbs.7cuu.com/?1 [收藏] [复制] [分享] [RSS]

日志

p139-1

已有 386 次阅读2009-11-17 08:04 |个人分类:C语言

#include <stdio.h>
int main()
{
 int n,a[10],i,tempd,tempx,indexd,indexx;
 printf("Enten n:");
 scanf("%d",&n);
 tempd=0;
 tempx=999;
 for(i=0;i<n;i++){
  printf("Enten a[i]:");
  scanf("%d",&a[i]);
  if(a[i]>=tempd){
   tempd=a[i];
   indexd=i;
  }
  else if(a[i]<=tempx){
   tempx=a[i];
   indexx=i;
  }

 }
 a[indexd]=a[n-1];
 a[indexx]=a[0];
 a[0]=tempx;
 a[n-1]=tempd;
 for(i=0;i<n;i++)
  printf("%d  ",a[i]);
}


路过

雷人

握手

鲜花

鸡蛋

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 注册

QQ|QQ客服|联系我们|Archiver|手机版|小黑屋|悉远网络 ( 鄂ICP备09013446号 )

GMT+8, 2024-5-17 11:13 , Processed in 0.028763 second(s), 6 queries , Redis On.

Powered by Discuz! X3.5

Copyright © 2001-2023 Tencent Cloud.

返回顶部