Welcome![Sign In][Sign Up]
Location:
Search - num

Search list

[Graph programWrite Num Identify.rar

Description:
Platform: | Size: 214751 | Author: | Hits:

[Other用c编写的N*N的螺旋矩阵源代码

Description:

/*
实现效果:
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列的

 


Platform: | Size: 4395 | Author: good@588 | Hits:

[Graph RecognizeWrite Num Identify

Description: 联机手写数字识别的全部源码,主要用到了图像处理和模式识别的知识,大家参考一下哟!-Online descript number recognition with all code.Mainly used the knowledge of image disposes.
Platform: | Size: 215018 | Author: 刘英 | Hits:

[Otheri263tb32

Description: 中国网站网贴吧程序源码(ASP+ACCESS) 实现功能: 多级分类查找,可按多级分类查找贴吧,多用户申请,任何人都可以申请自己的贴吧, 用户三种权限管理,1,普通会员,2,普通版主(只有管理自己的贴吧),3,高级版主(可管理全部贴吧),用户积分统计,登陆次数,发主题帖,回帖,精华数等等多功能统计,ip锁定,会员锁定,在线举报,在线申请版主,密码取回等,其他的就不说了,自己看演示,该版做到了整站全后台设置,包括,网站名称,网站logo,地址,站长名称,qq号码,贴图帮助文件编辑,注册条款规则编辑,用户必读信息编辑等,全部在后台完成,免去对代码不熟悉的朋友还要编辑页面代码. 管理帐号/密码:admin-China Network website message boards procedures source (ASP ACCESS) functionality : multi-category search, multi-category may find message boards, multi-user application, a person can apply for their own message boards, user management competence of the three, an ordinary member, 2, general moderator (only management has its own message boards), 3, senior moderator (management affixed it all), users integral statistics, the number of landing, the theme invitations and replies, the best of several multi-purpose statistics, etc., ip lock, lock members, online reporting, online Shenqing, passwords, etc. back , the others are not saying it, do you demonstrate that the version of the entire station do all the background settings, including the site name, site logo, address, station name, qq num
Platform: | Size: 1520250 | Author: 蔡思洋 | Hits:

[Windows Develop砝码问题

Description: 若允许天平两边放砝码,times应从-num[index]开始,并且分段计算sum,本例只放天平一边.?? -if allowed to put weight on both sides of scales, from the times-num [index], and sub-calculated sum, the cases take only balance the side.
Platform: | Size: 3272 | Author: 姚天伟 | Hits:

[Other复数六种基本运算

Description: S1:打印菜单 S2:输入所选功能的序号 S3:接收输入的数据(NUM) S4:判断是否超出范围 S4.1 满足条件执行后续语句 S4.2退出重选 S5:运行所选功能 -S1 : Print menu S2 : input function of the selected serial numbers S3 : receiving input data (NUM) S4 : judgment beyond Consistency conditions for the implementation of the follow-up to meet S4.2 statement from the election S5 : Run the selected function
Platform: | Size: 1454 | Author: 刘新夏 | Hits:

[Other resourceDelphi快捷键

Description: DELPHI basicCtrl+NUM 直接将光标跳到NUM处,NUM是用Ctrl+Shift+NUM设置的标号。 NUM不能用小键盘。 Ctrl+Home 将光标移至文件头。 Ctrl+End 将光标移至文件尾。 Ctrl+B Buffer List窗口。 Ctrl+I 同Tab键。 Ctrl+M 同Enter键。 Ctrl+N 同Enter键,但光标位置保持不变。 Ctrl+T 删除光标右边的一个单词。 Ctrl+Y 删除光标所在行。 Ctrl+Shift+↑ 光标在函数体内时,将光标快速移至当前函数声明处。 Ctrl+Shift+↓ 光标在函数声明行时,将光标快速移至函数定义处。 Ctrl+Shift+C 声明一个过程或函数后,直接生成过程或函数的名称、begin、end Ctrl+Shift+E 光标在Edit窗口和Explorer窗口间切换。 Ctrl+Shift+G 插入GUID。 Ctrl+Shift+J 弹出Delphi语句提示窗口,选择所需语句将自动完成一条语句。 Ctrl+Shift+T 在光标行加入To-Do注释。 Ctrl+Shift+Y 删除光标之后至本行末尾之间的文本。 Ctrl+F3 Call Stack窗口。 Ctrl+F4 等于File菜单中的Close项。
Platform: | Size: 2516 | Author: 小强 | Hits:

[Othercaculate.the.num.of.each.word.in.a.document

Description: 图形化界面,用于统计英文文档里的各个字母出现次数与频率-graphical interface for statistical files in the English alphabet in various frequency and the frequency
Platform: | Size: 33937 | Author: 张阿三 | Hits:

[Other resourceavr-gcc-display-led-num.move

Description: avr-gcc编写的数字移位显示程序,使用AVR单片机,avr studio编译环境下编译通过。-avr - gcc prepared by the displacement figures show, the use of AVR, avr studio compiler environment compile.
Platform: | Size: 61106 | Author: 王克敏 | Hits:

[WEB CodeDiscuz_DIAOYONG

Description: Discuz! 4.0.0 首页公告,论坛新帖简单调用.mahuzi.php请放在论坛根目录中 在首页调用代码 type=0表示调用公告,可以省略,type=1表示调用论坛帖子. 调用公告num=n 表示显示n条, <script src=\"bbs/mahuzi.php?num=4\"></script> 调用最新帖子num=n表示调用最新n条,fid是论坛编号 <script src=\"bbs/mahuzi.php?num=4&fid=4&type=1\"> -BBS! 4.0.0 Home Notice new Forum TIE simple call. please put mahuzi.php Forum in the root directory called Home code type = 0 call notice said, can be omitted. type = Call said a forum message. Call Notice num = n n said of the show,
Platform: | Size: 1387 | Author: 顾荣胜 | Hits:

[MPINUM-FDTDVer1.0unix

Description: 利用不均一分割的FDTD解析程序,为了适应正确表现小型天线的局部部位的细小构造,还有包含电介质材料的电磁场问题而由本研究室开发的解析法。这种解析法可以提高解析效率,并且因为正确表现天线的细小构造,也可以达到提高解析结果精度的目的。-use an uneven division of FDTD analytical procedures, In order to adapt to the correct performance of the local small antenna parts of the small structure, There dielectric material contains the electromagnetic field from the Development Research Center of the analytical method. This analytical method can improve the efficiency analysis, and because the correct performance of a small antenna structure, can achieve greater analytical accuracy of the results.
Platform: | Size: 8192 | Author: 崔宏青 | Hits:

[Embeded-SCM DevelopXW-PLC

Description: 是法国NUM数控系统1006的PLC控制软件。-France NUM CNC system of PLC control software 1006.
Platform: | Size: 9216 | Author: 王欣 | Hits:

[SCMPS2command.tar

Description: ps2键盘的命令集,编写键盘驱动时有用。EDH:置位/复位 LED 指示器。键盘右上角有三个 LED 指示器,分别反映 Caps、Num 和 Scroll 三个键的 锁定情况。参数字节如表 2 所列。 -ps2 keyboard command set, the preparation of useful keyboard-driven. EDH: Set/reset LED indicator. The upper right corner of the keyboard has three LED indicators, respectively, reflecting the Caps, Num and Scroll Lock keys in three cases. Parameter bytes as listed in Table 2.
Platform: | Size: 114688 | Author: 刘刚 | Hits:

[Graph Recognizenum

Description: 手写数字识别之Fisher线性判别,手写数字识别之Fisher线性判别-num
Platform: | Size: 27648 | Author: lm | Hits:

[matlabmatlab-sym-char-num

Description: matlab sym格式转换成char型和数值型的简易算法-sym convert to char or num simple algorithm
Platform: | Size: 2048 | Author: Liu Kevin | Hits:

[Software Engineeringmethodes-num

Description: résoudre des eqts diff par les méthodes num
Platform: | Size: 19456 | Author: mahdi | Hits:

[OtherCaps-and-Num-Lock-Status

Description: Visual Basic Caps Lock NUM Lock shower
Platform: | Size: 487424 | Author: Liam Stuart | Hits:

[Data structsthe-num-k-element

Description: 寻找中项和第k小元素 通过使用线性时间分析的数学方法 从而找到第k小元素 而不用排序以后再找-you can find the middle element and the num k element in a array which is not originally sorted
Platform: | Size: 1024 | Author: vincent | Hits:

[JSP/Javaconnect-four-num

Description: connect four numconn ect four num-connect four numconnect four numconnect four numconnect four num
Platform: | Size: 1024 | Author: GK | Hits:

[OtherUntitled 4

Description: labview Num
Platform: | Size: 45056 | Author: cheng12345 | Hits:
« 12 3 4 5 6 7 8 9 10 ... 30 »

CodeBus www.codebus.net