https://www.myziyuan.com/
- 000000
- #include <stdio.h>//包含标准输入输出流头文件void print();//申明一个函数int main(int argc, char* argv[]){ int number = 1000;//申明一个整型变量并赋值为1000 printf("这是一个控制台程序number 的值为 %d\n", number); //打印一句话,其中%d将被number的值代替 print();//调用print函数 return 0;//返回0来表示程序正常结束}void print()//实现申明的函数{ int i;//声明一个未初始化的变量 for(i=1; i<=10; i++)//建立一个循环,循环十次 { printf("i的值为 %d\n", i);//输出循环控制变量的值 }}
- 2021-03-04 09:45:01
- 苹果cms
- 采用广度优先搜索即可,程序如下:char A[64][64]= {"..###","#....","#.#.#","#.#.#","#.#.."};//迷宫,A,R,C这里预设,实际请改成输入 int M[64][64] = {0}, //标记走过的点 R = 5, C = 5; //判断点(x,y)是否可达bool pass(int x, int y) { return x>=0 && x<=R && y>=0 && y<=C && A[x][y]=='.' && !M[x][y];}//广度搜索int steps(){ struct{ int x, y, depth;}Queue[256], t; //队列 int front = 0, rear = 0, //头尾指标 di[4][2] = {{1,0},{0,-1},{-1,0},{0,1}}; //方向数组 int i, new_x, new_y; Queue[rear].x = 0; //初始点入队 Queue[rear].y = 0; Queue[rear++].depth = 1; M[0][0] = 1; //标记该店 while(front != rear) { t = Queue[front++]; //出队 for(i=0; i<4; i++) //遍历每个方向 { new_x = t.x+di[i][0]; //产生新的坐标 new_y = t.y+di[i][1]; if(pass( new_x, new_y)) //若可达 { if(new_x==R-1 && new_y==C-1)return t.depth+1; //结束条件 //入队 Queue[rear].x = new_x; Queue[rear].y = new_y; Queue[rear++].depth = t.depth+1; M[new_x][new_y] = 1; //同样标记入队的点 } } } return -1; //无法走到终点,返回-1}int main(){ printf("%d", steps());}
- 2021-02-12 05:30:07
- lyrhc
- c语言程序设计实例,给你一个,我自己编的:#include "stdio.h"int _judge(int x){ if(x%400==0) return(1); else if(x%4==0&&x%100!=0) return(1); else return(0);}int _fun(int year,int month,int day){ int i,sum=0,a[12]={31,29,31,30,31,30,31,31,30,31,30,31}; if(_judge(year)==1) { for(i=0;i<month-1;i++)sum+=a[i]; sum+=day; } else { a[1]=28; for(i=0;i<month-1;i++)sum+=a[i]; sum+=day; } return(sum);}void main(){ int year,month,day; printf("Please input the year,month and day:\n"); scanf("%d,%d,%d",&year,&month,&day); printf("The %dth day in the %dth month of the year %d ",day,month,year); printf("is the %dth day of this year.\n",_fun(year,month,day));}主要是要分闰年平年。所以有一个判断。
- 2021-02-12 05:30:07