第五题求解c语言求解方程组

c语言 循环结构 第5题_百度知道
c语言 循环结构 第5题
答题抽奖
首次认真答题后
即可获得3次抽奖机会,100%中奖。
采纳数:50
获赞数:49
20次a for(j=0; j&4; j++) 这个是 从0到3 是4次for(i=5; i--) 从5到1 是5次 一共20次啊= =ps 你学的好认真=。=
Hjc_卧龙待天
Hjc_卧龙待天
采纳数:48
获赞数:40
擅长:暂未定制
为你推荐:
其他类似问题
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。#include &stdio.h&
#include &string.h&
//分别从S,T开始进行DFS深度优先算法
//使用两个DFS
//60分 修改版
//如果玩家在初始位置就已经不能到达终点了,就输出“I'm stuck!”(不含双引号)。
//正确 100
// I'm stuck!
// 6 5 //5 6反过来
void DFS(int NUM1,int NUM2,int* color,char* c,int x,int y)
//printf("DFS1 %d %d=%c\n",x,y,*(c+x*NUM2+y));
//color[x][y]=1;
*(color+x*NUM2+y)=1;//NUM1改为NUM2 +10
//if((c[x][y]=='S')||(c[x][y]=='+')||(c[x][y]=='T'))
if((*(c+x*NUM2+y)=='S')||(*(c+x*NUM2+y)=='+')||(*(c+x*NUM2+y)=='T'))
if((x-1)&=0)
//if((color[x-1][y]==0)&&(c[x-1][y]!='#'))
if((*(color+(x-1)*NUM2+y)==0)&&(*(c+(x-1)*NUM2+y)!='#'))
//printf("up1\n");
DFS(NUM1,NUM2,color,c,x-1,y);
if((x+1)&NUM1)
//if((color[x+1][y]==0)&&(c[x+1][y]!='#'))
if((*(color+(x+1)*NUM2+y)==0)&&(*(c+(x+1)*NUM2+y)!='#'))
//printf("down1\n");
DFS(NUM1,NUM2,color,c,x+1,y);
if((y-1)&=0)
//if((color[x][y-1]==0)&&(c[x][y-1]!='#'))
if((*(color+x*NUM2+y-1)==0)&&(*(c+x*NUM2+y-1)!='#'))
//printf("left1\n");
DFS(NUM1,NUM2,color,c,x,y-1);
if((y+1)&NUM2)
//if((color[x][y+1]==0)&&(c[x][y+1]!='#'))
if((*(color+x*NUM2+y+1)==0)&&(*(c+x*NUM2+y+1)!='#'))
//printf("right1\n");
DFS(NUM1,NUM2,color,c,x,y+1);
}else if(*(c+x*NUM2+y)=='-')//else if(c[x][y]=='-')
if((y-1)&=0)
//if((color[x][y-1]==0)&&(c[x][y-1]!='#'))
if((*(color+x*NUM2+y-1)==0)&&(*(c+x*NUM2+y-1)!='#'))
//printf("left1\n");
DFS(NUM1,NUM2,color,c,x,y-1);
if((y+1)&NUM2)
//if((color[x][y+1]==0)&&(c[x][y+1]!='#'))
if((*(color+x*NUM2+y+1)==0)&&(*(c+x*NUM2+y+1)!='#'))
//printf("right1\n");
DFS(NUM1,NUM2,color,c,x,y+1);
}else if(*(c+x*NUM2+y)=='|')//else if(c[x][y]=='|')
if((x-1)&=0)
//if((color[x-1][y]==0)&&(c[x-1][y]!='#'))
if((*(color+(x-1)*NUM2+y)==0)&&(*(c+(x-1)*NUM2+y)!='#'))
//printf("up1\n");
DFS(NUM1,NUM2,color,c,x-1,y);
if((x+1)&NUM1)
//if((color[x+1][y]==0)&&(c[x+1][y]!='#'))
if((*(color+(x+1)*NUM2+y)==0)&&(*(c+(x+1)*NUM2+y)!='#'))
//printf("down1\n");
DFS(NUM1,NUM2,color,c,x+1,y);
}else if(*(c+x*NUM2+y)=='.')//else if(c[x][y]=='.')//NUM1没变成NUM2 +30
if((x+1)&NUM1)
//if((color[x+1][y]==0)&&(c[x+1][y]!='#'))
if((*(color+(x+1)*NUM2+y)==0)&&(*(c+(x+1)*NUM2+y)!='#'))
//printf("down1\n");
DFS(NUM1,NUM2,color,c,x+1,y);
void _DFS(int NUM1,int NUM2,int* color,char* c,int x,int y)
//printf("DFS2 %d %d=%c\n",x,y,*(c+x*NUM2+y));
//color[x][y]=1;
*(color+x*NUM2+y)=1;
if((x-1)&=0)
//if((color[x-1][y]==0)&&(c[x-1][y]!='#'))
if((*(color+(x-1)*NUM2+y)==0)&&(*(c+(x-1)*NUM2+y)!='#'))
//if((c[x-1][y]=='.')||(c[x-1][y]=='+')||(c[x-1][y]=='|')||(c[x-1][y]=='S')||(c[x-1][y]=='T'))
if((*(c+(x-1)*NUM2+y)=='.')||(*(c+(x-1)*NUM2+y)=='+')||(*(c+(x-1)*NUM2+y)=='|')||(*(c+(x-1)*NUM2+y)=='S')||(*(c+(x-1)*NUM2+y)=='T'))
//printf("up2\n");
_DFS(NUM1,NUM2,color,c,x-1,y);
if((x+1)&NUM1)
//if((color[x+1][y]==0)&&(c[x+1][y]!='#'))
if((*(color+(x+1)*NUM2+y)==0)&&(*(c+(x+1)*NUM2+y)!='#'))
//if((c[x+1][y]=='+')||(c[x+1][y]=='|')||(c[x+1][y]=='S')||(c[x+1][y]=='T'))
if((*(c+(x+1)*NUM2+y)=='+')||(*(c+(x+1)*NUM2+y)=='|')||(*(c+(x+1)*NUM2+y)=='S')||(*(c+(x+1)*NUM2+y)=='T'))
//printf("down2\n");
_DFS(NUM1,NUM2,color,c,x+1,y);
if((y-1)&=0)
//if((color[x][y-1]==0)&&(c[x][y-1]!='#'))
if((*(color+(x)*NUM2+y-1)==0)&&(*(c+(x)*NUM2+y-1)!='#'))
//if((c[x][y-1]=='+')||(c[x][y-1]=='-')||(c[x][y-1]=='S')||(c[x][y-1]=='T'))
if((*(c+(x)*NUM2+y-1)=='+')||(*(c+(x)*NUM2+y-1)=='-')||(*(c+(x)*NUM2+y-1)=='S')||(*(c+(x)*NUM2+y-1)=='T'))
//printf("left2\n");
_DFS(NUM1,NUM2,color,c,x,y-1);
if((y+1)&NUM2)
//if((color[x][y+1]==0)&&(c[x][y+1]!='#'))
if((*(color+(x)*NUM2+y+1)==0)&&(*(c+(x)*NUM2+y+1)!='#'))
//if((c[x][y+1]=='+')||(c[x][y+1]=='-')||(c[x][y+1]=='S')||(c[x][y+1]=='T'))
if((*(c+(x)*NUM2+y+1)=='+')||(*(c+(x)*NUM2+y+1)=='-')||(*(c+(x)*NUM2+y+1)=='S')||(*(c+(x)*NUM2+y+1)=='T'))
//printf("right2\n");
_DFS(NUM1,NUM2,color,c,x,y+1);
int main()
int NUM1;//行数
int NUM2;//列数
scanf("%d",&NUM1);
scanf("%d",&NUM2);
char c[NUM1][NUM2];
for(i=0;i&NUM1;i++)
for(j=0;j&NUM2;j++)
scanf(" %c",&c[i][j]);
int color[NUM1][NUM2];
memset(color,0,sizeof(color));
int a[NUM1][NUM2];
memset(a,0,sizeof(a));
int b[NUM1][NUM2];
memset(b,0,sizeof(b));
for(i=0;i&NUM1;i++)
for(j=0;j&NUM2;j++)
if(c[i][j]=='S')
DFS(NUM1,NUM2,color[0],c[0],i,j);
for(m=0;m&NUM1;m++)
for(n=0;n&NUM2;n++)
a[m][n]=color[m][n];
printf("S\n");
for(m=0;m&NUM1;m++)
printf("\n");
for(n=0;n&NUM2;n++)
printf("%d ",color[m][n]);
printf("\n");*/
memset(color,0,sizeof(color));
if(c[i][j]=='T')
_DFS(NUM1,NUM2,color[0],c[0],i,j);
for(m=0;m&NUM1;m++)
for(n=0;n&NUM2;n++)
b[m][n]=color[m][n];
printf("T\n");
for(m=0;m&NUM1;m++)
printf("\n");
for(n=0;n&NUM2;n++)
printf("%d ",color[m][n]);
printf("\n");*/
memset(color,0,sizeof(color));
for(i=0;i&NUM1;i++)
for(j=0;j&NUM2;j++)
if(c[i][j]=='T')
if(a[i][j]==0)
printf("I'm stuck!");
int kaoshi=0;
for(i=0;i&NUM1;i++)
for(j=0;j&NUM2;j++)
if((a[i][j]==1)&&(b[i][j]==0))
printf("%d",kaoshi);
printf("\n%d %d\n",NUM1,NUM2);
for(i=0;i&NUM1;i++)
for(j=0;j&NUM2;j++)
if(c[i][j]=='T')
printf("%c",c[i][j]);
printf("\n");
CCF之I’m stuck!(java)
试题编号:
试题名称:
I’m stuck!
时间限制:
内存限制:
201312-5 I'm stuck!
CCF-CSP-2013-12-5 I’m stuck!
题目:问题描述  给定一个R行C列的地图,地图的每一个方格可能是'#', '+', '-', '|', '.', 'S', 'T'七个字符中的一个,分别表示如下意思:  '#': 任何时候玩家都不能移...
试题名称:
I’m stuck!
时间限制:
内存限制:
问题描述:
  给定一个R行C列的地图,地图的每一个方格可能是'#', '+',...
CCF 201312-5
I’m stuck!(BFS)
  给定一个R行C列的地图,地图的每一个方格可能是'#', '+', '-', '|', '.', 'S', 'T'七个字符中的一个,分别表示如下意思:
  '#': 任何时候玩家都不能...
CSP 201312-5
I’m stuck! 两次BFS
试题编号:
试题名称:
I’m stuck!
时间限制:
内存限制:
CCF 习题 201312-5 I’m stuck! (BFS)
题意不说了,中文的题意。
普通的bfs即可!
第一个bfs,判断由起点是否可以到达终点,并且从起点能到达的点标记出来!(方便第二个bfs),如果可以到达终点,ok =1 ,最后只需要判断...
没有更多推荐了,c语言大神 麻烦帮我做下第5题_百度知道
c语言大神 麻烦帮我做下第5题
答题抽奖
首次认真答题后
即可获得3次抽奖机会,100%中奖。
Scorpio_qcl
Scorpio_qcl
采纳数:143
获赞数:89
#include&&stdio.h&int&i,j,&Selection_Sort(int&a[10])&{&printf(&\n排序前输出:&);&for(i=0;&i&10;&i++)&printf(&%-5d&,a[i]);&for(i=0;&i&10;&i++)&{&&for(j=i+1;&j&=9;&j++)&{&&&if(a[i]&a[j])&{&&&&temp=a[i];&&&&a[i]=a[j];&&&&a[j]=&&&}&&}&}}&Binary_Search(int&a[10])&{&int&mid=5,hight=10,N&printf(&\n请输入要查找的数:&);&scanf(&%d&,&New);&if(New==a[mid-1])&{&&printf(&\n此数所在的位置为%d\n&,mid);&&temp=1;&}&else&if(New&a[mid])&{&&for(i=0;&i&&i++)&{&&&if(a[i]==New)&{&&&&printf(&\n此数所在的位置在第%d个\n&,i+1);&&&&temp=1;&&&&&&&}&&}&}&else&{&&for(j=&j&10;&j++)&{&&&if(a[j]==New)&{&&&&printf(&\n此数所在的位置在第%d个\n&,j+1);&&&&temp=1;&&&&&&&}&&}&}&if(temp!=1)&printf(&\n没有查找到此数\n&);}&main()&{&int&a[10];&for(i=0;&i&10;&i++)&{&&printf(&请输入第%d个数:&,i+1);&&scanf(&%d&,&a[i]);&}&Selection_Sort(a);&Binary_Search(a);&printf(&\n排序后的位置为:&);&for(i=0;&i&10;&i++)&printf(&%-5d&,a[i]);&printf(&\n\t满意请采纳!&谢谢&);}这是源代码,,如果有不对或者可以改进的地方我很乐意一起探讨。
为你推荐:
其他类似问题
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。C语言程序设计-第5章-习题 - 答案_百度文库
您的浏览器Javascript被禁用,需开启后体验完整功能,
享专业文档下载特权
&赠共享文档下载特权
&100W篇文档免费专享
&每天抽奖多种福利
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
C语言程序设计-第5章-习题 - 答案
&&C语言程序设计基础
阅读已结束,下载本文需要
定制HR最喜欢的简历
下载文档到电脑,同时保存到云知识,更方便管理
加入VIP
还剩2页未读,
定制HR最喜欢的简历
你可能喜欢C语言编程求第五题答案,如图_百度知道
C语言编程求第五题答案,如图
答题抽奖
首次认真答题后
即可获得3次抽奖机会,100%中奖。
在网上问答案是一个不好的习惯,我只能说你这样成绩是不会提高的,另外也没动力,自己想想有什么让你有动力的事,不管是为自己还是为了自己喜欢的人!不要求答案,自己做最好。作业嘛作业,既然是作业 就要用心去完成 如果给你答案的话 对你是不负责任的表现。先问同学,再问老师,一步一步来。
想了一天了,一点思路都没有
为你推荐:
其他类似问题
您可能关注的内容
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。}

我要回帖

更多关于 c语言迷宫求解 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信