c++

xzhf0816 2008-10-28 10:06:37
#include"string.h"
#include"stdio.h"
#include"time.h"
#define MAXSIZE 60
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define OVERFLOW -1
typedef int Status;
typedef struct std_info{
int Num;
char Name[8];
float Score;
}
ElemType;
上面是库函数

#include"sj.h" 这里是调用上面的库函数
typedef struct
{
int elem[MAXSIZE];
int top;
}SeqStack;
void InitStack_sq(SeqStack *s)
{
s->top=-1;
}
Status Empty_sq(SeqStack *s)
{
return (s->top==-1);
}
void conversion(int N,int R)
{
SeqStack *S;
int x;
InitStack_sq(S);
while(N)
{
S->top++;
S->elem[S->top]=N%R;
N=N/R; }
printf("the result is\n");
while(!Empty_sq(S))
{
x=S->elem[S->top];
S->top--;
printf("%d",x);}
}

void main()
{
int Num,r;
printf("qingshuruzhuanhuanshuzhi\n");
scanf("%d,%d",&Num,&r);
if ((Num>=0)&&(r>0))
conversion(Num,r);
else printf("INput Error!");
}
请大家帮一下忙找一下上面有什么错误,问什么说S没有定义
谢了
...全文
94 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
太乙 2008-10-29
  • 打赏
  • 举报
回复
ls的,#include<iostream>
using namespace std;

lz可是c代码!
太乙 2008-10-29
  • 打赏
  • 举报
回复
#include"string.h" 
#include"stdio.h"
#include"time.h"
#define MAXSIZE 60
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define OVERFLOW -1
typedef int Status;
typedef struct std_info{
int Num;
char Name[8];
float Score;
} ElemType;

typedef struct
{
int elem[MAXSIZE];
int top;
}SeqStack;
void InitStack_sq(SeqStack *s)
{
s->top=-1;
}
Status Empty_sq(SeqStack *s)
{
return (s->top==-1);
}
void conversion(int N,int R)
{
SeqStack *S;
int x;
InitStack_sq(S);
while(N)
{
S->top++;
S->elem[S->top]=N%R;
N=N/R; }
printf("the result is\n");
while(!Empty_sq(S))
{
x=S->elem[S->top];
S->top--;
printf("%d",x);}
}

void main()
{
int Num,r;
printf("qingshuruzhuanhuanshuzhi\n");
scanf("%d,%d",&Num,&r);
if ((Num>=0)&&(r>0))
conversion(Num,r);
else printf("INput Error!");
}
e_sharp 2008-10-29
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 xzhf0816 的回复:]
用VC++运行不了啦!!
缩进代码是什么意思啊?
还有就是你《《#include <iostream>
using namespace std;》》是什么意思啊!!!~?
大哥啊!!!
帮帮忙咯!!
[/Quote]

#include <iostream> //引用头文件 iostream
using namespace std; //引用std名字空间,看看c++的名字空间就知道什么意思了
xzhf0816 2008-10-29
  • 打赏
  • 举报
回复
用VC++运行不了啦!!
缩进代码是什么意思啊?
还有就是你《《#include <iostream>
using namespace std;》》是什么意思啊!!!~?
大哥啊!!!
帮帮忙咯!!
xzhf0816 2008-10-29
  • 打赏
  • 举报
回复
我也不懂了
那是别人改的
Jncryang 2008-10-28
  • 打赏
  • 举报
回复

#include"string.h"
#include"stdio.h"
#include"time.h"
#include <iostream>
using namespace std;
#define MAXSIZE 60
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define OVERFLOW -1

typedef int Status;

typedef struct std_info{
int Num;
char Name[8];
float Score;
}ElemType;

typedef struct
{
int elem[MAXSIZE];
int top;
}SeqStack;

void InitStack_sq(SeqStack *s)
{
s->top=-1;
}
Status Empty_sq(SeqStack *s)
{
return (s->top==-1);
}
void conversion(int N,int R)
{
SeqStack *S = new SeqStack;
int x;
InitStack_sq(S);
while(N)
{
S->top++;
S->elem[S->top]=N%R;
N=N / R;
}
printf("the result is\n");
while(!Empty_sq(S))
{
x=S->elem[S->top];
S->top--;
printf("%d",x);
}
}

void main()
{
int Num,r;
printf("请输入转换数字\n");
cin >> Num >> r;
if ((Num >= 0) && (r > 0))
{
conversion(Num,r);
}
else
{
printf("INput Error!");
}
}
xzhf0816 2008-10-28
  • 打赏
  • 举报
回复
不懂意思
  • 打赏
  • 举报
回复
这代码 连缩进都没有啊

65,210

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧