Welcome![Sign In][Sign Up]
Location:
Search - v.35

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:

[Internet-NetworkE1与V.35标准说明

Description: E1与V.35标准说明及E1与V.35信号转换的实现方法。-E1 and V.35 standard descriptions and E1 and V.35 signal conversion method.
Platform: | Size: 13779 | Author: 张城 | Hits:

[Internet-NetworkE1与V.35标准说明

Description: E1与V.35标准说明及E1与V.35信号转换的实现方法。-E1 and V.35 standard descriptions and E1 and V.35 signal conversion method.
Platform: | Size: 13312 | Author: 张城 | Hits:

[SCMSupplicant3.35

Description: 锐捷是校内网通用的登陆软件,这是个升级版,暂时不能实现共享。-Rui Jie is a landing with the school Netcom software, this is a upgraded version of the time being not to share.
Platform: | Size: 3256320 | Author: anqweihong | Hits:

[SCMmakemp3

Description: 、支持mp3, wma, wav, mid SF0播放 2、支持三种播放模式:单曲重复,全曲重复,乱序播放 3、支持任意文件夹文件的播放(注:总文件夹数不大于136个) 4、支持完整歌词显示(GBK超大字库,支持简繁体,推荐歌词形式为多个时间tag复用歌词的形式) 如 [00:12][00:35][00:56]歌词1 对时间tag没有要求,总之就是完全符合规范。 5、6个按键,next,prev,V+,V-,(PLSY/PAUSE),mode/BL 6、支持2G以内sd卡 -, Support mp3, wma, wav, mid SF0 player 2, in support of the three player modes: single, repeat, all song repeat, out-of-order player 3, support for arbitrary file player folder (Note: the total number of folders is not more than 136 ) 4, to support the integrity of the lyrics display (GBK large font, to support simplified and traditional, the form of a number of recommended time lyrics tag reuse the form of the lyrics) in the case [00:12] [00:35] [00:56] lyrics 1 tag does not require time, a word that is in full compliance with the norms. 5,6 a button, next, prev, V+, V-, (PLSY/PAUSE), mode/BL 6, within the sd card support 2G
Platform: | Size: 3261440 | Author: wuyan | Hits:

[Windows DevelopWindows_Driver_Programming_Tutorial

Description: 第一章 字符串 6 1.1 使用字符串结构 6 1.2 字符串的初始化 7 1.3 字符串的拷贝 8 1.4 字符串的连接 8 1.5 字符串的打印 9 第二章 内存与链表 11 2.1内存的分配与释放 11 2.2 使用LIST_ENTRY 12 2.3 使用长长整型数据 14 2.4使用自旋锁 15 第三章 文件操作 18 3.1 使用OBJECT_ATTRIBUTES 18 3.2 打开和关闭文件 18 3.3 文件的读写操作 21 第四章 操作注册表 25 4.1 注册键的打开操作 25 4.2 注册值的读 26 4.3 注册值的写 29 第五章 时间与定时器 30 5.1 获得当前滴答数 30 5.2 获得当前系统时间 31 5.3 使用定时器 32 第六章 内核线程 35 6.1 使用线程 35 6.2 在线程中睡眠 36 6.3 使用事件通知 37 第七章 驱动与设备 41 7.1 驱动入口与驱动对象 41 7.2 分发函数与卸载函数 41 7.3 设备与符号链接 42 7.4 设备的生成安全性限制 44 7.5 符号链接的用户相关性 46 第八章 处理请求 47 8.1 IRP与IO_STACK_LOCATION 47 8.2 打开与关闭的处理 48 8.3 应用层信息传入 49 8.4 驱动层信息传出 51 后记:我的闲言碎语 54 -Chapter 6 Strings 1.1 The structure of 6 string 1.2 initialization string 7 1.3 copy of the string 8 1.4 connection string 8 1.5 string printing 9 Chapter II memory and list 11 2.1 memory allocation and release of 11 2.2 Use LIST_ENTRY 12 2.3 The use of a long integer 14 2.4 The use of spin locks 15 Chapter 18 File Operation 3.1 Use OBJECT_ATTRIBUTES 18 3.2 to open and close the file 18 3.3 file read and write operations 21 Chapter IV Operation registry 25 4.1 registration key open operation 25 4.2 read 26 registered value 4.3 The value of the write register 29 Chapter V Time and Timer 30 5.1 to obtain the current number of 30 ticks 5.2 to obtain the current system time 31 5.3 using the timer 32 Chapter VI kernel thread 35 6.1 using threads 35 6.2 In the thread sleep 36 6.3 use the event notification 37 Chapter VII of the driver and equipment 41 7.1 Drive entrance and the driver object 41 7.2 Distribution Functions and unloading function, 41 7.3 Equipment
Platform: | Size: 70656 | Author: chenzifeng | Hits:

[JSP/JavaLab3

Description: Understand and apply exponentiation-Wind chill is the apparent temperature felt by exposed skin on a cold, windy day. Normally, there is a thin layer of warm air surrounding our bodies, and this warm air helps insulate us from the cold air around us. A strong wind reduces the amount of insulation by this air layer, so our skin loses heat at a faster rate than it would otherwise. Our skin feels colder, which makes us feel colder the temperature it "feels like" is the wind chill temperature. For example, if you re exposed to 30°F air moving at 20 mph, your skin loses heat at the same rate it would in calm 17.4°F air, so the windchill is 17.4°F. In 2001, the National Weather Service changed the formula used to calculate the wind chill index (the old formula produced temperatures that were too low). The new formula is: Wind Chill (in °F) = 35.74+ 0.6215 T- 35.75 (V0.16)+ 0.4275 T (V0.16) where T is the air temperature in °F and V is the wind velocity in mph. (In case your browser has trouble showing it, V0.16 me
Platform: | Size: 2048 | Author: Chenli | Hits:

[OtherBestQuestionToAskOnYourInterview

Description: PART I THE RULES OF THE GAME 1 Chapter 1: Why You Have to Question 3 Chapter 2: Questions You Should Never Initiate 25 Chapter 3: When to Question 35 Chapter 4: Do Your Homework 41 Chapter 5: Do You Mind If I Take Notes? 49 PART II INTERVIEW THE INTERVIEWER 57 Chapter 6: Questions for Headhunters, Recruiters, 59 and Staffing Agencies Chapter 7: Questions for Human Resources 69 Chapter 8: Questions for Hiring Managers 81 For more information about this book, click here. Copyright 2002 The McGraw-Hill Companies, Inc. Click Here for Terms of Use. PART III THE QUESTION LIFE CYCLE 103 Chapter 9: Exploring Questions 109 Chapter 10: Defensive Questions 117 Chapter 11: Feedback Questions 123 Chapter 12: Bid-for-Action Questions 127 Chapter 13: Questions for Superstars 139 Chapter 14: You Got an Offer. Congratulations! 147 Chapter 15: You Blew the Interview. Now What? 153 Index of Questions 161 Index 189 v-PART I THE RULES OF THE GAME 1 Chapter 1: Why You Have to Question 3 Chapter 2: Questions You Should Never Initiate 25 Chapter 3: When to Question 35 Chapter 4: Do Your Homework 41 Chapter 5: Do You Mind If I Take Notes? 49 PART II INTERVIEW THE INTERVIEWER 57 Chapter 6: Questions for Headhunters, Recruiters, 59 and Staffing Agencies Chapter 7: Questions for Human Resources 69 Chapter 8: Questions for Hiring Managers 81 For more information about this book, click here. Copyright 2002 The McGraw-Hill Companies, Inc. Click Here for Terms of Use. PART III THE QUESTION LIFE CYCLE 103 Chapter 9: Exploring Questions 109 Chapter 10: Defensive Questions 117 Chapter 11: Feedback Questions 123 Chapter 12: Bid-for-Action Questions 127 Chapter 13: Questions for Superstars 139 Chapter 14: You Got an Offer. Congratulations! 147 Chapter 15: You Blew the Interview. Now What? 153 Index of Questions 161 Index 189 vii
Platform: | Size: 524288 | Author: venkata ramana | Hits:

[Windows Developv.35

Description: V.35的接口定义,这是一个通用的定义,希望对大家有所帮助!-v.35
Platform: | Size: 2048 | Author: 白棉田 | Hits:

[Algorithmwccc

Description: (1)已知甲数的35 是36,甲数是( )。已知乙数的47 是12,乙数是( )。   (2)40分钟是1小时的( ),1小时的35 是( )分钟。 (3)铅笔的单价是钢笔的920 ,把( )看作单位“1”。 二、根据算式补充条件   (1)停车场有24辆大汽车,( ),有多少辆小汽车?     24÷23   (2)停车场有24辆大汽车,( ),有多少辆小汽车?     24×23   (3)停车场有24辆小汽车,( ),有多少辆大汽车?     24×13 三、应用题   (1)一个长方体的宽是长的23 ,长是高的56 ,它的宽是10厘米,它的高是多少厘米?   (2)六年级(2)班学生人数是本年的学生人数的13 ,六年级学生人数是全校的16 ,如果六(2)班有学生48人,全校有学生多少人? 参考答案 一、 (1)60 ,21 (2)23 ,36 (3)钢笔的单价 二、 (1)正好是小汽车的23 -Th e i nf o r ma t i o n o f e n v i r on me n t c o n s t r a i n s a nd pa t h l e n g t h Wa s i n t e g r a t e d i n t he f it n e s s f un c t i o n whi c h Wa s c o mp ut e d by n e u r a l n e t wo r k,t h e pa t h no de s wa s v i e we d a s a p a r t i c l e,8 0 wi t h t h e qu a l i t y o f o p t i mi z a t i o n o f h y br id p a r t i c l e s wa r m a lg o . r i t h m,a b e s t p a t h W a s f o u n d .F i n a ll y b y c o mp u t e r s i mu l a t i o n,i t i s p r ov e d t h a t t h e a l g o r i t h m i s r a t i o n a l a n d c a n b e u s e d i n mo — bi l e r ob o t r e a l— t i me n a v i g a t i o n
Platform: | Size: 4096 | Author: wanchao | Hits:

[matlabfinalUKF

Description: 二维近似匀速运动模型 目标速度:V=150 并且与X轴的夹角为35度 假设传感器静止不动 -ukf
Platform: | Size: 2048 | Author: caoxiang | Hits:

[VHDL-FPGA-VerilogV35interface-communicate

Description: V.35接口与E1接口之间转换的基本原理,介绍了E1信道分时隙通信的基本过程,叙述了基于FPGA用VHDL和QuartusII来仿真本系统设计与实现的过程。-V.35 interface and E1 interface to convert between the basic principles of E1 channel introduces the basic process of communication sub-time slot, described by VHDL and FPGA-based QuartusII to simulate the system design and implementation process.
Platform: | Size: 1323008 | Author: 汪涵 | Hits:

[DSP program3977

Description: A3977是一个完整的微电机驱动,与内建 翻译。它的设计操作双极步进电机 全,半,季,和第八步的模式,与输出驱动器 35 V和±2.5答:A3977的功能包括一个固定 关断时间电流稳压器,具有操作能力 慢,快或混合衰减模式 -The A3977 is a complete microstepping motor driver, with builtin translator. It is designed to operate bipolar stepper motors in full-, half-, quarter-, and eighth-step modes, with output drive capability of 35 V and ±2.5 A. The A3977 includes a fixed off-time current regulator that has the ability to operate in slow-, fast-, or mixed-decay modes
Platform: | Size: 710656 | Author: bin | Hits:

[ARM-PowerPC-ColdFire-MIPS9262176A3977

Description: A3977 带转换器的微步 DMOS 驱动器 特点 ±2.5 A、35 V 输出额定值 低 rDS(开)输出(一般为 0.45 Ω源极,0.36Ω灌电流) 自动检测/选择电流-A3977 DMOS drive characteristics with micro-step converter ± 2.5 A, 35 V output rating of low, rDS (open) output (typically 0.45 Ω source very, 0.36Ω current sink) automatically detect/select current
Platform: | Size: 477184 | Author: 郑欢欢 | Hits:

[Special Effectsfigure5_34_2

Description: 数字图像处理(第二版)第五章例题5.35的实现代码。有关几何变换失真及其恢复的代码。-Digital Image Processing (second edition) Chapter V, Example 5.35 code. The geometric transformation distortion and its recovery code.
Platform: | Size: 1024 | Author: 沈沆瑜 | Hits:

[Picture Viewerft235

Description: Freetype is for font program v.2.35
Platform: | Size: 2170880 | Author: CLChen | Hits:

[File FormatMicrostepping_DMOS_Driver_with_Translator

Description: The A3977 is a complete microstepping motor driver, with builtin translator. It is designed to operate bipolar stepper motors in full-, half-, quarter-, and eighth-step modes, with output drive capability of 35 V and ±2.5 A.
Platform: | Size: 466944 | Author: kiam | Hits:

[JSP/JavaAssignment-1

Description: Wind Chill. Given the temperature t (in Fahrenheit) and the wind speed v (in miles per hour), the US National Weather Service defines the effective temperature (the wind chill) to be: w = 35.74 + 0.6215t + (0.4275 t - 35.75)v 0.16 Write a program that takes two double command-line arguments t and v and prints out the wind chill. Note: The formula is not valid if t is larger than 50 in absolute value or if v is larger than 120 or less than 3. You may assume that the values you get are in the range. Important: Your program must have a single public class called WindChill, which contains the main method as per the following template:
Platform: | Size: 2048 | Author: NIKS | Hits:

[OtherZozo-Tabs----Regular-License---v.6.5

Description: Zozo Tabs is a user-friendly, fully customizable, responsive jQuery tabs plugin to take any HTML content, including images, videos and display it in a clean organised and responsive tabbed navigation. It works out of the box, making it simple to create beautiful but powerful enough to build branded and highly customized tabs. This plugin features plenty of layouts , vertical tabs, horizontal tabs, responsive tabs, deep-linking, Flat Theme Pack Extension, powerfull API, CSS transitions and animations, 6+ sizes, 30+ themes, 35+ templates, 10+ positions, 65+ options and much more.
Platform: | Size: 311296 | Author: gourkhatt | Hits:

[Program docPhysical-Layer-Serial-Interface-Standards

Description: Overview Physical Layer Interface Standards (PSTN) EIA RS-232-C/D, V.24, V.28, RS-423-A, RS-422-A, RS-449, EIA-530, V.35, USB, Hierarchy ITU - T V series.
Platform: | Size: 224256 | Author: | Hits:
« 12 »

CodeBus www.codebus.net