当前位置: 代码迷 >> C语言 >> 求助高手的分析
  详细解决方案

求助高手的分析

热度:414   发布时间:2008-06-22 11:42:04.0
能啊,你自己看懂后慢慢改

[color=white]

[[it] 本帖最后由 爱喝牛奶的猫咪 于 2008-6-22 11:48 编辑 [/it]]
----------------解决方案--------------------------------------------------------
饭都送到手上了,难道还要我们飞燕大美女来喂么?
----------------解决方案--------------------------------------------------------
[bo][un]StarWing83[/un] 在 2008-6-22 11:53 的发言:[/bo]

饭都送到手上了,难道还要我们飞燕大美女来喂么?

如果是帅GG的话,偶来喂他也不成问题


[color=white]
----------------解决方案--------------------------------------------------------
tk190960 同学,发照片吧……
----------------解决方案--------------------------------------------------------
LS是不是心理不平衡? - -
----------------解决方案--------------------------------------------------------
我干嘛心理不平衡?只是看看是不是帅哥而已嘛,如果是的,那就麻烦飞燕大美女喂饭咯
----------------解决方案--------------------------------------------------------
天哪 咱别这样
我自己改了一下 目前就剩那个 选择的排序还排不出来 帮忙挑下错吧
#include<stdlib.h>
#include<stdio.h>
#include<time.h>
void Insert_Sort(int R[],int n )
{
    int i,j;
        for(i=2;i<=n;i++)
            if(R[i]<R[i-1])
                {
                    R[0]=R[i];
                    for(j=i-1;R[0]<R[j];j--)
                    R[j+1]=R[j];
                    R[j+1]=R[0];
                }
}
void PopSort(int R[],int n )
{
    int i,j,x,a[100000];
                for(j=0;j<99999;j++)
                    for(i=0;i<99999-j;i++)
                        if(a[i]>a[i+1])
                        {
                            x=a[i];
                            a[i]=a[i+1];
                            a[i+1]=x;
                        }
}
void SelectSort(int R[],int n )

    {            
        int i,j,x,k,a[100000];
                for(i=0;i<99999;i++)        
                    {
                        x=i;
                for( j=i+1;j<100000;j++ )
                    {
                        if( a[x]>a[j] )
                        x=j;
                    }
                    k=a[i];
                    a[i]=a[x];
                    a[x]=k;
                    }
    }
void main()
{
    
    
        int i,j,x,k;
            int a[100000];
        srand((unsigned)time(NULL));
            for(i=0;i<100000;i++)
            {    
                k=rand()%100;
                a[i]=k;
                printf("k=%d\n",k);
            }
            {
            {
    clock_t start;
    clock_t end;
    float t;
    start=clock();                
                {
            int i,n=100000;
            SelectSort(a,n);
                }
                for(i=0;i<100000;i++)
                    printf("%d\n",a[i]);                                    
            end=clock();
            t=(float)(end-start)/(float)CLOCKS_PER_SEC;
            printf("%f",t);
            }                
                {
    clock_t start;
    clock_t end;
    float t;
    start=clock();
                {
            int i,n=100000;
            Insert_Sort(a,n);
                }
                for(i=0;i<100000;i++)
                printf("%d\n",a[i]);            
            end=clock();
            t=(float)(end-start)/(float)CLOCKS_PER_SEC;
            printf("%f",t);
            }
{    
    clock_t start;
    clock_t end;
    float t;
    start=clock();
    {
            int i,n=100000;
            PopSort(a,n);
                }
                for(i=0;i<100000;i++)
                printf("%d\n",a[i]);
            end=clock();
            t=(float)(end-start)/(float)CLOCKS_PER_SEC;
            printf("%f",t);
            }                        

    }
}
----------------解决方案--------------------------------------------------------
void SelectSort(int R[],int n )

    {            
        int i,j,x,k,a[100000];
                for(i=0;i<99999;i++)        
                    {
                        x=i;
                for( j=i+1;j<100000;j++ )
                    {
                        if( a[x]>a[j] )
                        x=j;
                    }
                    k=a[i];
                    a[i]=a[x];
                    a[x]=k;
                    }
    }
----------------解决方案--------------------------------------------------------
哪里错了啊 谢谢
----------------解决方案--------------------------------------------------------
int i,j,x,k,a[100000];
栈空间有那么大么?
----------------解决方案--------------------------------------------------------
  相关解决方案