关于我的项目的问题....... [英] question about my project.......

查看:130
本文介绍了关于我的项目的问题.......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道错误的原因是什么.
我用c ++&我发送关于它的内容.
这是代码:

i don''t know what is the reason of of error.
i write it with c++ & i send what is it about.
it is the code:

<big>#include <iostream><br />#include <string><br />#include <cctype><br />using namespace std;<br />class cart{<br />public:<br />	cart(char a[2]="paq"){<br />		cout << a[0]<<a[1]<<a[2];};<br />	char left()<br />	{//int i;<br />		char a[2];<br />	swap(a[0],a[1]);<br />	//i++;<br />		for (int b=1;b>=2;b++)<br />			cout << a[b];<br />	return ''L'';<br />	};<br /><br />    char right()<br />	{//int i;<br />		char  a[2];<br />	swap(a[2],a[1]);<br />	//i++;<br />		for (int b=1;b>=2;b++)<br />	cout << a[b];<br />	return ''R'';<br />	};<br /><br />    char en()<br />	{//int i;<br />		char  a[2];<br />	swap (a[0],a[2]);<br />	//i++;<br />		for (int b=1;b>=2;b++)<br />	cout << a[b];<br />	return ''E'';<br />	};<br />	char fo()<br />	{ //int i;<br />//	i++;<br />		char  a[2];<br />		for (int b=1;b>=2;b++)<br />	cout << a[b];<br />	return ''F'';<br />	};<br />};<br /><br />int main ()<br />{cout << "swap the cart juker1,ace,juker2" <<endl;<br /><br />char b[50];char a[2];a[0]=''p'';a[1]=''a'';a[2]=''q'';<br />for (int i=1;i>=50;i++){<br />	cin >>b[i];<br />	if (b[i]=''.'') break;<br />};<br />	//cart y("p","a","q");<br />	cart x;<br />	for (int i=1;i>=50;i++){<br />	if ((b[i]=''l'')|(b[i]=''L''))  x.left(); <br />	else if ((b[i]=''r'')|(b[i]=''R'')) x.right();<br />	else if ((b[i]=''e'')|(b[i]=''E'')) x.en();<br />	else if ((b[i]=''f'')|(b[i]=''F'')) x.fo();<br />	};}</big>


这就是我想要做的:
     ;
他有一张桌子,该桌子连续三张面朝上的纸牌:两个小丑和一个王牌,中间有王牌.进行小额下注后,他将牌面朝下并开始操纵牌,一次交换两张牌.他完成掉期之后,您就可以猜出哪张牌是ace.
一系列掉期将按顺序作为String掉期给您,其中只包含字符"L","R" ","E"和"F". swaps [0]表示第一次交换. 4个字符表示以下移动:
L:交换左侧和中间卡
R:交换右侧和中间卡
E:交换两端的卡(左侧和右侧的卡)
F:伪掉期(没有牌实际改变位置)
在完成所有掉期后,编写一个方法返回ace的最终位置.如果左卡为ace,则方法应返回"L";如果右卡为ace,则方法应返回"R",如果中间为ace,则返回"M".
感谢关注

推荐答案

1)听起来像是作业-我们不做作业-充其量我们会给您提示,但是如果您希望我们参与其中,解决您所有的问题,请转到RentACoder或类似的

2)不要变得过时且过时-多数人在这里有工作要做,我怀疑我们中有人会得到酬劳以帮助其他人CP-除了CP员工本人以外,他们中的大多数人都参与了网站的实际运行,没有回答正确的论坛中的问题3)在正确的论坛中发帖-表明您可以这样做表明您有一定的智力水平-否则,您得到的响应将是"trite"(如果不是),这是残酷的

一些建议:-

1)显示您得到的输出-或在哪里出现编译错误或此类-我认为您实际上并未说明问题/问题是什么

2)假定您的代码可以编译:学习如何使用调试器-使用F10/F11单步执行程序,在执行过程中检查变量的内容等-或最糟糕的是,打印出它们的内容,然后逐步

3)评论您的代码-如果您听不懂,也无法告诉我们每一块是什么这样做,我们都不会花很多时间

4)查看您的代码,我认为您需要重新阅读教科书,..例如char a [2] ="paq" ..好的,因此,如果"a"是大小为"2"的字符数组,则您要在其中填充多少个字符-可能是3个?我不确定您使用的是哪种编译器,但我可以在MSVC(6)中告诉您,您将收到错误C2117:" paq":数组边界溢出"

''g''
1) this sounds like homework - we dont do homework - at best we will give you hints, but if you''re expecting us to jump in and solve all your issues, go to RentACoder or such

2) DONT GET IMPATIENT AND POST MORE THAN ONCE - most of us here have jobs we get paid to do, I doubt any of us get paid to help others on CP - except CP staff themselves, and most of them are involved with the actual running of the site, not answering questions

3) post in the correct forum - showing that you can do so indicates some level of intelligence - else, the responses you get will be rather ''trite'' if not, brutal

Some suggestions :-

1) show what output you get - or where there''s a compile error or such - I dont think you''ve actually stated what the problem/issue is

2) assuming your code compiles : learn how to use the debugger - use F10/F11 to single step through your program, inspect the contents of variables etc as you go - or at worst, print out their contents, then walk through what you''re trying to do ''on paper'' and see if that tells you whats going wrong.

3) comment your code - if you cant understand it, and cant tell us what each piece is doing, we wont spend much time on it either

4) looking at your code, I think you need to go back through your textbooks, a bit more .. for example char a[2]="paq" .. ok, so, if ''a'' is a character array of size ''2'', how many characters are you trying to stuff in there - perhaps 3 ?? Im not sure what compiler you are using, but I can tell you in MSVC(6) you''ll get "error C2117: ''paq'' : array bounds overflow"

''g''


这篇关于关于我的项目的问题.......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆