Hot Search : Source embeded web remote control p2p game More...
Location : Home Search - DO-17
Search - DO-17 - List

/*
实现效果:
1 2 6 7 15
3 5 8 14 16
4 9 13 17 22
10 12 18 21 23
11 19 20 24 25
*/
#include <stdio.h>
#define N 5 //阶数,即N*N的螺旋矩阵

void main()
{
    int i, j, num=1, a[N][N];
    for(i=0; i<=N/2; i++)
    {
        for(j=i; j<N-i; j++) a[i][j]=n++;
        for(j=i+1; j<N-i; j++) a[j][N-i-1]=n++;
        for(j=N-i-2; j>i; j--) a[N-i-1][j]=n++;
        for(j=N-i-1; j>i; j--) a[j][i]=n++;
    }
    for(i=0; i<N; i++)
    {
        for(j=0; j<N; j++)
            printf("%2d ",a[i][j]);
        printf("\n");
    }
}
    

 

不知道叫什么,先叫它“回宫图”吧
年初的时候在贴吧瞎逛,看到了一个程序挺有意思,会输出如下的形状:
01 24 23 22 21 20 19
02 25 40 39 38 37 18
03 26 41 48 47 36 17
04 27 42 49 46 35 16
05 28 43 44 45 34 15
06 29 30 31 32 33 14
07 08 09 10 11 12 13
仔细看这个形状,数字是按顺序往里回旋的,觉得很有创意,可是一看源代码头就大了,
每个编程人都知道看别人的代码是很困难的,尤其像这种不知道思路的,所以也就放下
没管了。
昨天上物理课实在是没心思听,就想起这个程序,想了一节课,果然不负有心人,给弄出来了,这个是增强版的,可以输入1-10中的任意个数,然后生成图形。
先看代码,没有注释,所以不好看的懂。
#include<stdio.h>
main()
{
       int n,m,i,j,t,k=1;
       int a[11][11];
       clrscr();
       do{
       printf("please input a number(1-10):");
       scanf("%d",&n);
       }while(n<1||n>10);
       t=n+1;
       for(m=1;m<=t/2;m++)
         {
           for(i=m;i<=t-m;i++)
             {a[i][m]=k;k++;}
           for(j=m+1;j<=t-m;j++)
             {a[i-1][j]=k;k++;}
           for(i=n-m;i>=m;i--)
             {a[i][j-1]=k;k++;}
           for(j=n-m;j>=m+1;j--)
             {a[i+1][j]=k;k++;}
         }
       for(i=1;i<=n;i++)
         {
           for(j=1;j<=n;j++)
             {
               if(a[i][j]<=9) printf("0%d ",a[i][j]);
               else printf("%d ",a[i][j]);       }
           printf("\n");
         }
       getch();
}
就是这样的。


可以更简洁些:

#include<stdio.h>
main()
{
       int n,m,i,j,t,k=1;
       int a[11][11];
       clrscr();
       do{
       printf("please input a number(1-10):");
       scanf("%d",&n);
       }while(n<1||n>10);
       t=n+1;
       for(m=1;m<=t/2;m++)
         {
           for(i=m;i<=t-m;i++)
             a[i][m]=k++;
           for(j=m+1;j<=t-m;j++)
             a[i-1][j]=k++;
           for(i=n-m;i>=m;i--)
             a[i][j-1]=k++;
           for(j=n-m;j>=m+1;j--)
             a[i+1][j]=k++;
         }
       for(i=1;i<=n;i++)
         {
           for(j=1;j<=n;j++)
             {
               if(a[i][j]<=9) printf("0%d ",a[i][j]);
               else printf("%d ",a[i][j]);       }
           printf("\n");
         }
       getch();
}

 


 #include <stdio.h>
#define N 8
main(){
 int i,j,n=1,a[N][N];
 for(i=0;i<=N/2;i++){
  for(j=i;j<N-i;j++)
   a[i][j]=n++;
  for(j=i+1;j<N-i;j++)
   a[j][N-i-1]=n++;
  for(j=N-i-2;j>i;j--)
   a[N-i-1][j]=n++;
  for(j=N-i-1;j>i;j--)
   a[j][i]=n++;
 }
 for(i=0;i<N;i++){
  printf("\n\n");
  for(j=0;j<N;j++)
   printf("%5d",a[i][j]);
 }
}
 

 


                                马踏棋盘问题


#include <stdio.h>
#define N 5
void main(){
 int x,y;
 void horse(int i,int j);
 printf("Please input start position:");
 scanf("%d%d",&x,&y);
 horse(x-1,y-1);
}
void horse(int i,int j){
 int a[N][N]={0},start=0,
  h[]={1,2,2,1,-1,-2,-2,-1},
  v[]={2,1,-1,-2,2,1,-1,-2},
  save[N*N]={0},posnum=0,ti,tj,count=0;
 int jump(int i,int j,int a[N][N]);
 void outplan(int a[N][N]);
 a[i][j]=posnum+1;
 while(posnum>=0){
  ti=i;tj=j;
  for(start=save[posnum];start<8;++start){
   ti+=h[start];tj+=v[start];
   if(jump(ti,tj,a))
    break;
   ti-=h[start];tj-=v[start];
  }
  if(start<8){
   save[posnum]=start;
   a[ti][tj]=++posnum+1;
   i=ti;j=tj;save[posnum]=0;
   if(posnum==N*N-1){
    //outplan(a);
    count++;
   }
  }
  else{
   a[i][j]=0;
   posnum--;
   i-=h[save[posnum>;j-=v[save[posnum>;
   save[posnum]++;
  }
 }
 printf("%5d",count);
}
int jump(int i,int j,int a[N][N]){
 if(i<N&&i>=0&&j<N&&j>=0&&a[i][j]==0)
  return 1;
 return 0;
}
void outplan(int a[N][N]){
 int i,j;
 for(i=0;i<N;i++){
  for(j=0;j<N;j++)
   printf("%3d",a[i][j]);
  printf("\n");
 }
 printf("\n");
 //getchar();
}
用回溯法得到所有的解,但效率较低,只能算出5行5列的

 


Update : 2008-05-05 Size : 4.29kb Publisher : good@588

17.如何实现图像的雾化效果?这个PHOTOSHOP效果的图怎么用VC做出来呢?-17. How to achieve image atomizing effect? The effects of Photoshop with VC map how to do it?
Update : 2008-10-13 Size : 37.04kb Publisher : 黄庆龙

DL : 0
主要功能如下:1、不用注册也可以发言,注册的话保留用户名;2、可以设置多个管理员;3、两种留言显示方式:留言本式和讨论区式,并可进行固定设置;4、管理员可以删除、固顶、锁定、提前和反向操作留言;5、留言可选心情图标;6、发帖人IP记录,管理员可查看;7、注册用户可以修改自己的留言;8、留言可按留言主题、留言内容、回复内容、留言人进行搜索;9、可设置是否必须注册才能留言;10、可设置是否只能管理员或版主才能回复;11、可设置过滤词语;12、可设置被过滤词语后是否禁止该用户再次留言; 13、留言锁定功能,使锁定留言不能回复;14、可设定是否要经过认证才能显示留言;15、可同时对多个留言进行管理操作;16、用户可发悄悄话,只有该用户和管理员或版主才能查看;17、防灌水功能,可设置用户留言时间间隔;18、可禁止一些IP用户的留言;19、两级管理员,版主只有对留言管理的权力,管理员有所有权力;20、带计数器功能,可在留言板后台设置;21、多用户回复留言功能,类似微型论坛;22、图文编辑混排功能,强大的文本编辑器。此为个人版。-main function is as follows : 1, do not have to register can also speak to retain the registered users; 2. administrators can set up a number; three, two displays messages : messages of this type and a discussion area - and may fixed set; 4, administrators can delete jacking, lock, early and contrarian voice; 5, voice mail optional mood icon; 6. people posting record IP, administrators can be found; 7, registered users can modify their own voice; 8. voice mail messages may be the theme, message, reply, message people search; 9. whether or not it can be registered before voice mail; 10, can be set only if administrators or moderator return; 11. Words can provide filtration; 12, the filter can be set to be banned words whether the user messages again; 13, voice mail lockout, so lock message
Update : 2008-10-13 Size : 670.37kb Publisher : qiu

17.如何实现图像的雾化效果?这个PHOTOSHOP效果的图怎么用VC做出来呢?-17. How to achieve image atomizing effect? The effects of Photoshop with VC map how to do it?
Update : 2025-02-19 Size : 203kb Publisher :

利用ATtiny45晶片自行開發製做遊戲控制器-ATtiny45 chips using self-developed system to do the game controller
Update : 2025-02-19 Size : 70kb Publisher : 吳小禾

DO-178B document The rapid license in the use of software in airbore system and equipment used on aircraft and engines
Update : 2025-02-19 Size : 3.41mb Publisher : LX

FINAL REPORT FOR CLARIFICATION OF DO-178B “SOFTWARE CONSIDERATIONS IN AIRBORNE SYSTEMS AND EQUIPMENT CERTIFICATION”-FINAL REPORT FOR CLARIFICATION OF DO-178B
Update : 2025-02-19 Size : 333kb Publisher : LX

IPServer_SDK_3.1.6.17对于普通宽带用户(如adsl拨号上网),设备每次启动后对应的IP地址是动态分配的,通过将设备DNS地址设置为IPServer的所在PC的IP地址,那么远端的客户可以通过查询IPServer上的设备注册信息获得设备对应的IP地址。如果设备不是直接架在公网上,那么需要在私网的网关上对设备的端口做映射,如设备与网络SDK的数据通讯端口(一般为8000,如果同一个私网内有多台设备,则要求设备的数据通讯端口不能重复,以防端口映射的时候出问题)。-IPServer_SDK_3.1.6.17 for ordinary broadband users (such as dial-up adsl), equipment, after each time you start the corresponding IP address is dynamically assigned by the equipment is set to DNS address IPServer where PC s IP address, so remote clients can through inquiries IPServer of the equipment on the registration information to obtain equipment corresponding IP address. If the device is not directly mounted on the public Internet, then the need for the private network gateway equipment to do the port mapping, such as equipment and network SDK data communication port (usually 8000, if the same multiple Private network equipment request data communications equipment port can not be repeated in order to prevent problems when port mapping).
Update : 2025-02-19 Size : 683kb Publisher : jcl

DL : 0
用AVR单片机做的MzL02的驱动程序,可在0XOE和0XEE之间添加自己的代码就可,用的软件是IAR4.1-Using AVR to do the MzL02 single-chip driver can be 0XOE and between 0XEE add your own code you can use the software is IAR4.1
Update : 2025-02-19 Size : 12kb Publisher : 肖若进

带时钟的台历:一个非常非常漂亮的仿真电子台历,不用可惜-Clock with calendar: a very, very nice simulation of electronic desk calendar, do not pity
Update : 2025-02-19 Size : 1kb Publisher :

The project is a VNC viewer written in C#. Do try this out
Update : 2025-02-19 Size : 84kb Publisher : sarah

DBISAM v4.17 System will automatically delete the directory of debug and release, so please do not put files on these two directory.
Update : 2025-02-19 Size : 473kb Publisher : hansolo101

遗传算法做排课软件源码!写的非常不错,利用遗传算法实现了快速排课!-Timetabling software source code genetic algorithm to do! Very well written!
Update : 2025-02-19 Size : 1.22mb Publisher : 冯云

DL : 0
用FLASH AS3制作的简单计算器,可以计算四种简单的算术。-caculator made by Flash AS3,can do four kinds of caculation.
Update : 2025-02-19 Size : 10kb Publisher : qinjiayue

实现窗口17分屏,左侧右侧分屏,右侧分为4*4的窗口,对做界面的朋友来说是很给力的参考代码。-Implementation 17 screens, window on the left side of the split screen on the right, the right side of the window is divided into 4* 4, for friends do interface is great reference code.
Update : 2025-02-19 Size : 7.03mb Publisher : 李映

DL : 1
用c语言编写的ATM联系,虽然界面简单,但是适合初学者做联系使用-ATM using c language contact, although the interface is simple, but do contact use suitable for beginners
Update : 2025-02-19 Size : 3kb Publisher : 杨凯

application to be executed compares version of the client / server and copies the new version. aplicaç ã o ao ser executada compara versã o do cliente/servidor e copia nova versã o.
Update : 2025-02-19 Size : 227kb Publisher : Fabricio

DL : 0
一款基于java和mysql的酒店管理系统-DO IT
Update : 2025-02-19 Size : 603kb Publisher : liudeyuan

石器脱机外挂,用于挂机练级,捉宠,做任务,合成等(Stone Age auxiliary software for normal hang up and do the task)
Update : 2025-02-19 Size : 4.29mb Publisher : 风雨自在

DL : 0
马克斯CMS(Maxcms)5,想你所想,做你做的事!让视频站更容易使用!马克斯程序(Maxcms)开源,免费的,功能强大的,(Marx CMS (Maxcms) 5, do what you want and do what you do. Make video stations easier to use! Marx program (Maxcms) is open source, free and powerful.)
Update : 2025-02-19 Size : 1.84mb Publisher : 3wy4e5
« 12 3 4 5 »
CodeBus is one of the largest source code repositories on the Internet!
Contact us :
1999-2046 CodeBus All Rights Reserved.