• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
crucio
博客园    首页    新随笔    联系   管理    订阅  订阅
gravity
  1. #include <stdio.h>
    
    #include<stdlib.h>
    
    #include<string.h>
    
    int num[10];
    
    int test_main(int data[9]);
    
    //void build_data(int data[100])
    
    //{
    
    // for(int i=0;i<100;i++)
    
    // {
    
    //  data[i]=rand()%101;
    
    // }
    
    //}
    
    void main(void) {
    
       int data[9]={7,4,2,0,0,6,0,7,0};
    
       for(int l=0;l<10;l++)  {  
    
     //build_data(data);   
    
      printf("%d\n",test_main(data));  }
    
    }
    
     
    
    int test_main(int data[9]) {  
    
      int m,n,a,max;  
    
      memset(num,0,sizeof(num));  
    
      for(m=0;m<9;m++)  {   
    
          /*n=m+1;*/   
    
          /*while(data[m]>data[n])   {    
    
          n++;   
    
          num[m]++;   }*/   
    
          for( n=m+1;n<9;n++)   {   
    
            if(data[m]>data[n])     
    
            num[m]++;   }  }
    
       for(a=0,max=0;a<10;a++)  {   
    
        if(num[a]>max)   {    
    
        max=num[a];   }   
    
        else{max=max;}
    
     }  
    
    return max; }

    there is a room where boxes are stacked.If a room is rotated 90 degrees to the right,boxes will fall,affected by gravity.Write a c function which finds out a box which will have the longest 'fall distance',and returns the value of the longest 'fall distance'.

  2. 找出数组里最大的数
  3.  

posted on 2017-03-27 14:29  crucio  阅读(207)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3