Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

CÓïÑÔÖ¸Õ루Èý£©

¡¾Àý10.21¡¿ÓÃÑ¡Ôñ·¨¶Ô10¸öÕûÊýÅÅÐò¡£
main()
{int *p,i,a[10]={3,7,9,11,0,6,7,5,4,2};
printf("The original array:\n");
for(i=0;i<10;i++)
   printf("%d,",a[i]);
printf("\n");
p=a;
sort(p,10);
for(p=a,i=0;i<10;i++)
{printf("%d ",*p);p++;}
printf("\n");
}
sort(int x[],int n)
{int i,j,k,t;
for(i=0;i<n-1;i++)
   {k=i;
    for(j=i+1;j<n;j++)
      if(x[j]>x[k])k=j;
    if(k!=i)
    {t=x[i];x[i]=x[k];x[k]=t;}
    }
}
˵Ã÷£ºº¯ÊýsortÓÃÊý×éÃû×÷ΪÐβΣ¬Ò²¿É¸ÄΪÓÃÖ¸Õë±äÁ¿£¬Õâʱº¯ÊýµÄÊײ¿¿ÉÒÔ¸ÄΪ£º
sort(int *x,int n) ÆäËû¿ÉÒ»Âɲ»¸Ä¡£
10.3.4 Ö¸Ïò¶àάÊý×éµÄÖ¸ÕëºÍÖ¸Õë±äÁ¿
±¾Ð¡½ÚÒÔ¶þάÊý×éΪÀý½éÉܶàάÊý×éµÄÖ¸Õë±äÁ¿¡£
1. ¶àάÊý×éµÄµØÖ·
ÉèÓÐÕûÐͶþάÊý×éa[3][4]ÈçÏ£º
0   1   2   3
    4   5   6   7
8   9 10 11
ËüµÄ¶¨ÒåΪ£º
int a[3][4]={{0,1,2,3},{4,5,6,7},{8,9,10,11}}
ÉèÊý×éaµÄÊ×µØַΪ1000£¬¸÷ϱê±äÁ¿µÄÊ×µØÖ·¼°ÆäÖµÈçͼËùʾ¡£
Ç°Ãæ½éÉܹý£¬£ÃÓïÑÔÔÊÐí°ÑÒ»¸ö¶þάÊý×é·Ö½âΪ¶à¸öһάÊý×éÀ´´¦Àí¡£Òò´ËÊý×éa¿É·Ö½âΪÈý¸öһάÊý×飬¼´a[0]£¬a[1]£¬a[2]¡£Ã¿Ò»¸öһάÊý×éÓÖº¬ÓÐËĸöÔªËØ¡£
ÀýÈça[0]Êý×飬º¬ÓÐa[0][0]£¬a[0][1]£¬a[0][2]£¬a[0][3]ËĸöÔªËØ¡£
Êý×é¼°Êý×éÔªËصĵØÖ·±íʾÈçÏ£º
´Ó¶þάÊý×éµÄ½Ç¶ÈÀ´¿´£¬aÊǶþάÊý×éÃû£¬a´ú±íÕû¸ö¶þάÊý×éµÄÊ×µØÖ·£¬Ò²ÊǶþάÊý×é0ÐеÄÊ×µØÖ·£¬µÈÓÚ1000¡£a+1´ú±íµÚÒ»ÐеÄÊ×µØÖ·£¬µÈÓÚ1008¡£Èçͼ£º
a[0]ÊǵÚÒ»¸öһάÊý×éµÄÊý×éÃûºÍÊ×µØÖ·£¬Òò´ËҲΪ1000¡£*(a+0)»ò*aÊÇÓëa[0]µÈЧµÄ£¬ Ëü±íʾһάÊý×éa[0]0 ºÅÔªËصÄÊ×µØÖ·£¬Ò²Îª1000¡£&a[0][0]ÊǶþάÊý×éaµÄ0ÐÐ0ÁÐÔªËØÊ×µØÖ·£¬Í¬ÑùÊÇ1000¡£Òò´Ë£¬a£¬a[0]£¬*(a+0)£¬*a£¬&a[0][0]ÊÇÏàµÈµÄ¡£
ͬÀí£¬a+1ÊǶþάÊý×é1ÐеÄÊ×µØÖ·£¬µÈÓÚ1008¡£a[1]Êǵڶþ¸öһάÊý×éµÄÊý×éÃûºÍÊ×µØÖ·£¬Òò´ËҲΪ1008¡£&a[1][0]ÊǶþάÊý×éaµÄ1ÐÐ0ÁÐÔªËصØÖ·£¬Ò²ÊÇ1008¡£Òò´Ëa+1,a[1],*(a+1),&a[1][0]ÊǵÈͬµÄ¡£
Óɴ˿ɵóö£ºa+i£¬a[i]£¬*(a+i)£¬&a[i][0]ÊǵÈͬµÄ¡£
´ËÍ⣬&a[i]ºÍa[i]Ò²ÊǵÈͬµÄ¡£ÒòΪÔÚ¶þάÊý×éÖв»ÄÜ°Ñ&a[i]Àí½âΪԪËØa[i]µÄµØÖ·£¬²»´æ


Ïà¹ØÎĵµ£º

C %m.ns Êä³ö

#include <stdio.h>
#define N 19
int main()
{
int i;
for (i=0;i<=N;i++)
{
printf("%*.*s%-*.*s\n",N,i<=N/2?i:N-1,"*******************",\
N,i<=N/2?i+1:N-i+1,"*******************");
}
return 0;
}

%m.ns ......

¹ØÓÚ Ö¸Õë CµÄ¾«Ëè

ÒªÁ˽âÖ¸Õë,¶à¶àÉÙÉÙ»á³öÏÖһЩ±È½Ï¸´ÔÓµÄÀàÐÍ,ËùÒÔÎÒÏȽéÉÜ
Ò»ÏÂÈçºÎÍêÈ«Àí½âÒ»¸ö¸´ÔÓÀàÐÍ,ÒªÀí½â¸´ÔÓÀàÐÍÆäʵºÜ¼òµ¥,Ò»
¸öÀàÐÍÀï»á³öÏֺܶàÔËËã·û,ËûÃÇÒ²ÏñÆÕͨµÄ±í´ïʽһÑù,ÓÐÓÅÏÈ
¼¶,ÆäÓÅÏȼ¶ºÍÔËËãÓÅÏȼ¶Ò»Ñù,ËùÒÔÎÒ×ܽáÁËÒ»ÏÂÆäÔ­Ôò:
´Ó±äÁ¿Ãû´¦Æð,¸ù¾ÝÔËËã·ûÓÅÏȼ¶½áºÏ,Ò»²½Ò»²½·ÖÎö.
ÏÂÃæÈÃÎÒÃÇÏÈ´Ó¼òµ¥µÄÀàÐ ......

c/c++±ÊÊÔ


1£®½ø³ÌºÍÏ̵߳IJî±ð¡£
Ïß³ÌÊÇÖ¸½ø³ÌÄÚµÄÒ»¸öÖ´Ðе¥Ôª,Ò²Êǽø³ÌÄڵĿɵ÷¶ÈʵÌå.
Óë½ø³ÌµÄÇø±ð:
(1)µ÷¶È£ºÏß³Ì×÷Ϊµ÷¶ÈºÍ·ÖÅäµÄ»ù±¾µ¥Î»£¬½ø³Ì×÷ΪӵÓÐ×ÊÔ´µÄ»ù±¾µ¥Î»
(2)²¢·¢ÐÔ£º²»½ö½ø³ÌÖ®¼ä¿ÉÒÔ²¢·¢Ö´ÐУ¬Í¬Ò»¸ö½ø³ÌµÄ¶à¸öÏß³ÌÖ®¼äÒ²¿É²¢·¢Ö´ÐÐ
(3)ÓµÓÐ×ÊÔ´£º½ø³ÌÊÇÓµÓÐ×ÊÔ´µÄ¶ÀÁ¢µ¥Î»£¬Ï̲߳»ÓµÓÐϵͳ×ÊÔ´£¬µ«¿ÉÒ ......

C·¢Éù³ÌÐò

#include "stdafx.h"
#include <stdio.h>
#include <windows.h>
#include <math.h>
#include <conio.h>
typedef struct {
      short int pitch;
      short int duration;
} NOTE;
NOTE notes[] = {{14, 500}, {16, 500}, {12, 500 ......

LuaÓëC½»»¥ÈëÃÅ

 LuaÓëC½»»¥ÈëÃÅ
¼ò½é
LuaÓëC/C++½áºÏÊǺܽôÃܵÄ, LuaÓëC++½»»¥Êǽ¨Á¢ÔÚLuaÓëCµÄ»ù´¡ÉϵÄ, Ëù
ÒÔżÏÈ´ÓLuaÓëC½²Æð.
ÕýÈçµÚÒ»½²Ëù˵, ÔËÐÐLua³ÌÐò»òÕß˵µ÷ÓÃLuaÖ÷ÒªÓÐÁ½ÖÖ·½Ê½:
* ͨ¹ýÃüÁîÐÐÖ´ÐÐ"Lua"ÃüÁî
* ͨ¹ýLuaµÄC¿â
ËäÈ»´ËǰżÃÇÒ»Ö±ÓõÚÒ»ÖÖ·½Ê½, µ«Å¼Òª¸æËßÄã, ͨ¹ýLuaµÄC¿âÖ´ÐвÅÊÇÓÎÏ·ÖÐ
³£Óõķ½Ê½. ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ