Welcome![Sign In][Sign Up]
Location:
Search - t.38

Search list

[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:

[Communicationospsample

Description: Version number header file for simple OpenH323 sample T.38 transmitter.
Platform: | Size: 15437 | Author: yhw | Hits:

[Technology ManagementITU-T.38-chinese

Description: ITU-T T.38 国际电信联盟 电信标准化部门 (09/2005) T系列:用于远程信息处理业务终端 IP网络上三类传真实时传送通信规程 中文版和英文版, 本帖不付负任何版权问题。 -ITU-T T.38 ITU Telecommunication Standardization Sector (09/2005) T Series : information processing for remote terminal operations on three types of IP network fax communications protocols to transmit in real time the Chinese version and the English version. This afternoon did not pay any negative copyright issues.
Platform: | Size: 1365371 | Author: 刘剑 | Hits:

[VOIP programt38modem-0.8.4.tar

Description: Fax over VOIP 的 T.38协议的解析.
Platform: | Size: 59390 | Author: Tang | Hits:

[Fax programt38modem

Description: From your fax application view point it s a fax modem pool. From IP network view point it s a H.323 endpoint with T.38 fax support. From your view point it s a gateway between a fax application and IP network.
Platform: | Size: 57244 | Author: 郑江 | Hits:

[Fax programt38modem

Description: From your fax application view point it s a fax modem pool. From IP network view point it s a H.323 endpoint with T.38 fax support. From your view point it s a gateway between a fax application and IP network.
Platform: | Size: 57344 | Author: 郑江 | Hits:

[Communicationospsample

Description: Version number header file for simple OpenH323 sample T.38 transmitter.
Platform: | Size: 15360 | Author: yhw | Hits:

[Industry researcht38

Description: T38协议,网络传真应用到的东西-T38 agreement, network fax applications to the things
Platform: | Size: 798720 | Author: 杨先生 | Hits:

[Technology ManagementITU-T.38-chinese

Description: ITU-T T.38 国际电信联盟 电信标准化部门 (09/2005) T系列:用于远程信息处理业务终端 IP网络上三类传真实时传送通信规程 中文版和英文版, 本帖不付负任何版权问题。 -ITU-T T.38 ITU Telecommunication Standardization Sector (09/2005) T Series : information processing for remote terminal operations on three types of IP network fax communications protocols to transmit in real time the Chinese version and the English version. This afternoon did not pay any negative copyright issues.
Platform: | Size: 1364992 | Author: 刘剑 | Hits:

[VOIP programt38modem-0.8.4.tar

Description: Fax over VOIP 的 T.38协议的解析.-Fax over VOIP resolve the T.38 protocol.
Platform: | Size: 59392 | Author: Tang | Hits:

[Windows DevelopSCAN

Description: 扫描仪驱动开发范例 开发范例 说 明 文件名 大小(KB) 更新日期 4a,4b,4c扫描仪的DOS下的驱动及开发范例 4a.zip* 53 1998/09/21 Windows 环境Twain接口开发范例(16位) Twain.zip* 38 1998/09/21 Windows 环境Twain接口开发范例(32位) Twain32.zip* 62 1998/09/21 Windows 环境下扫描仪控制动态链接库(16位) scan16.zip* 10 1998/09/21 紫光笔开发范例 pendemo.zip* 47 1998/12/04 Wintab 标准 wtdoc.zip* 76 1998/12/04 Uniscan扫描仪扫描动态链接库(32位) (有用户控制界面) scan32.zip* 27 1998/09/21 Uniscan扫描仪扫描动态链接库(32位)(无用户控制界面) uniscan.zip 29 1999/06/25 -Scanner-driven development paradigm example of the development of the documentation of the size (KB) Updated 4a, 4b, 4c scanner driver under DOS and development paradigm 4a.zip* 53 1998/09/21 Windows environment for the development of an example of Twain interface (16-bit ) Twain.zip* 38 1998/09/21 Windows environment interface development paradigm Twain (32) Twain32.zip* 62 1998/09/21 Windows environment scanner control dynamic link library (16) scan16.zip* 10 1998/T 09/21 developed here an example of pendemo.zip* 47 1998/12/04 Wintab standards wtdoc.zip* 76 1998/12/04 Uniscan scanner dynamic link library (32) (a user control interface) scan32.zip* 27 1998/09/21 Uniscan scanner dynamic link library (32) (non-user control interface) uniscan.zip 29 1999/06/25
Platform: | Size: 324608 | Author: liming | Hits:

[Program docT[1].38-200404

Description: 了解网络传真的方法及相关细节,是写相关代码的好文档。-Understanding of network fax methods and relevant details, is to write good documentation related to the code.
Platform: | Size: 836608 | Author: 张生 | Hits:

[Fax programT38_Bandwidth

Description: bandwidth user by t.38 fax ca-bandwidth user by t.38 fax call
Platform: | Size: 148480 | Author: calfulcurajuan | Hits:

[Driver DevelopDriverVirus

Description: 实现了底层的自我保护和读写注册表功能,编译后ESET NOD32会报病毒-.LOG 13:12 03-9-14 Version 0.1 can write register when program is run. 13:23 03-9-15 Version 0.11 same as v0.1, but reprogrammed by asm, and only use one export symbol : IoCallDriver 8:38 03-9-16 Version 0.12 create or open a file any path, and can t be deleted.
Platform: | Size: 129024 | Author: robin | Hits:

[Communicationt38modem-1.0.0.tar

Description: T38FAX Pseudo Modem From your fax or voice application view point it s a fax/voice modem pool. From IP network view point it s a H.323 endpoint with T.38 fax support. From your view point it s a gateway between an application and IP network.
Platform: | Size: 96256 | Author: piowang | Hits:

[CommunicationITU-T.38-chinese

Description: ITU-T T38通信协议-ITU-T T38 communication protocol. . . . . . .
Platform: | Size: 1364992 | Author: yoyo | Hits:

[Modem programt38modem-2.0.0

Description: T.38传真,AT modem,传真modemIP传输-T.38 fax, AT modem, fax modemIP transmission
Platform: | Size: 175104 | Author: 李芳 | Hits:

[Fax programattrafax-0.9

Description: 一个包含t.30/T.38协议栈并且支持Asterisk ippbx system的传真解决方案。-The fax solution consists of a T.30/T.38 stack, with an example implementation for Asterisk (including gatewaying support).
Platform: | Size: 288768 | Author: test | Hits:

[Other systemsvoipmonitor-9.3-src.tar

Description: 广域网质量监控软件,VoIP Monitor 模块帮助您测定与跟踪最需要关注的广域网语音质量性能。-VoIPmonitor is open source network packet sniffer with commercial frontend for SIP SKINNY RTP and RTCP VoIP protocols running on linux. VoIPmonitor is designed to analyze quality of VoIP call based on network parameters- delay variation and packet loss according to ITU-T G.107 E-model which predicts quality on MOS scale. Calls with all relevant statistics are saved to MySQL or ODBC database. Optionally each call can be saved to pcap file with either only SIP/SKINNY protocol or SIP/RTP/RTCP/T.38/udptl protocols. VoIPmonitor can also decode audio.
Platform: | Size: 908288 | Author: raymond | Hits:

[androidlibrarysearch

Description: 广东海洋大学图书馆安卓源码可以获取网站(http://210.38.138.1:81/)上的图书信息,直接通过get/post模拟浏览器与网站交互,非json或webview方式,获取到返回html字符串再去取里面的元素,本项目的服务端是asp.net写的实现了图书系统的登录查询等,在做与asp.net网站交互的朋友可以看一下,登录部分因为我没有测试帐号所以就没有测试。不过项目很多地方没有做异常处理,返回空数据的时候应用会直接异常停止退出-Guangdong Ocean University Library an Android source code can obtain the book information in the website (http://210.38.138.1:81/), browser interaction with the web site directly through the get/post simulations and non JSON or WebView, get the returned HTML string again to pick up the inside elements and the project server is asp.net write the book system login query, in do with the ASP. Net web interaction of friends can look at, log in part because I don t have a test account so there is no test. However, many parts of the project did not do exception handling, return to empty data when the application will directly stop the exit
Platform: | Size: 4256768 | Author: 徐姗姗 | Hits:
« 12 »

CodeBus www.codebus.net