#c include iostream<iostream> #c include iostream<string> using namespace std; class CPerson { public: CPerson

 上传我的文档
 下载
 收藏
该文档贡献者很忙,什么也没留下。
 下载此文档
正在努力加载中...
期末考试代码复习
下载积分:5888
内容提示:C
期末考试代码复习
文档格式:DOC|
浏览次数:0|
上传日期: 14:22:55|
文档星级:
全文阅读已结束,如果下载本文需要使用
 5888 积分
下载此文档
该用户还上传了这些文档
期末考试代码复习
关注微信公众号#include&iostream& #include&string& class Csteak { char m_buff[100]; public : _百度知道
#include&iostream& #include&string& class Csteak { char m_buff[100]; public :
#include&iostream&#include&string&class Csteak{ char m_buff[100];public : int m_ Csteak() {
m_top=-1; } int push(char src)/*进栈*/ {
if(m_top&=98)
m_buff[m_top]=
else return 0; } int pop(char src)/*出栈*/ {
if(m_top!=-1)
m_buff[m_top]=
return 0; } char gettop(char x) {
x=m_buff[m_top];
m_top++; } }; int main(){
char str[100];
for(int i=0;i&strlen(str);i++) {
switch(str[i])
case'[':
case'(':
s.push(str[i]);
case ']':
s.gettop(e);
if(e=='[')
case')':
s.gettop(e);
if(e=='(');
if(s.m_top==0)
cout&&&匹配\n&;
cout&&&不匹配\n&;
return 0;}
为什么不对啊!
我有更好的答案
你程序里的错误不少。更改如下:#include&iostream&#include&string&class Csteak{
char m_buff[100];public :
int push(char src)/*进栈*/
if (m_top&=98)
m_buff[m_top]=
else return 0;
char pop()/*出栈*/
if (m_top!=-1)
src=m_buff[m_top];
char gettop()//这个函数只获取栈顶元素,不修改栈顶指针。
char x=m_buff[m_top];
}};int main(){
char str[100];
for (int i=0;i&strlen(str);i++)
switch (str[i])
case'[':
case'(':
s.push(str[i]);
case ']':
e=s.gettop();
if (e=='[')
case')':
e=s.gettop();
if (e=='(');
if (s.m_top==-1)//只有栈为空,才是匹配的。这是栈顶指针应为-1。
cout&&&匹配\n&;
cout&&&不匹配\n&;
return 0;}修改原因:1. pop和gettop函数应该把返回值放在return之后返回。放在形参里是不能返回的。2. 建议你看看函数传值、传址的区别。
采纳率:45%
为您推荐:
其他类似问题
iostream的相关知识
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。没有更多推荐了,
不良信息举报
举报内容:
#include &iostream.h& 和 #include &iostream& using namespace std的区
举报原因:
原文地址:
原因补充:
最多只允许输入30个字
加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!#include&iostream& template_百度知道
#include&iostream& template
#include&iostream&
template &typename T&
T max(T a,T b,T c)
(if (b&a) a=b;
if (c&a) a=c;
int main()
{int a,b,c,i1;
cin&&a&&b&&c;
double d,e,f,d1;
cin&&d&&e&&f;
long x,y,z,l1;
cin&&x,y,z;
i1=max(a,b,c);
我有更好的答案
把max改为max1,或者把#include &iostream&改为#include &iostream.h&
采纳率:72%
来自团队:
有什么运行异常情况。
发个截图看看。
1条折叠回答
为您推荐:
其他类似问题
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。#include &iostream& #include &string.h& int main(void) { char a[10],b[10];_百度知道
#include &iostream& #include &string.h& int main(void) { char a[10],b[10];
#include &iostream&#include &string.h&int main(void){ char a[10],b[10]; scanf(&%s&,a); printf(&\n&); gets(b);
return 0;}为什么无法输入字符串b
我有更好的答案
可以输入,没有问题,你可以这样输入:stringA stringB也可以这样输入:stringAstringB
如果写成这样#include &iostream&#include &string.h&int main(void){char a[10],b[10];scanf(&%s&,a);printf(&\n&);gets(b); printf(&哈哈哈n&);return 0;}那结果是直接输出了最后一个printf,把gets给跳过
输出不会影响输入的,scanf的结束符是键盘输入的空格或回车,而gets就是回车,这样gets会把scanf的结束符空格或者回车当成自己的结束符你可以最后将两个字符串打印出来看一下,比如:
你用的什么编译器?
采纳率:83%
来自团队:
为您推荐:
其他类似问题
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。

我要回帖

更多关于 include iostream.h 的文章

 

随机推荐