Error (char * message)函数是什么意思
答案:2 悬赏:30
解决时间 2021-02-21 22:08
- 提问者网友:清羽墨安
- 2021-02-21 11:14
#include
#include
#include
typedef int DataType;
typedef struct stacknode {
DataType data;
struct stacknode * next;
}StackNode;
typedef struct {
StackNode * top;
}LinkStack;
//错误信息
Error (char * message)
{
printf ("Erroe:%s",message);
exit (1);
}*/
//初始化链栈
void InitStack (LinkStack * s)
{
s->top = NULL;
}
//判栈空
int StackEmpty (LinkStack * s)
{
return s->top == NULL;
}
//入栈
void Push (LinkStack * s , DataType x)
{
StackNode * p = (StackNode * ) malloc (sizeof(StackNode));
p->data = x;
p->next = s->top;
s->top = p;
}
//出栈
DataType Pop(LinkStack *s)
{
DataType x;
StackNode * p = s->top;
if ( StackEmpty (s))
// Error ("下溢");
x = p->data;
s->top = p->next;
free (p);
return x;
}
//取栈顶
DataType StackTop (LinkStack* s)
{
if (StackEmpty (s))
// Error ("栈为空");
return s->top->data;
}
//数值转换
void MultiBaseOutput (int N,int B)
{
int i;
LinkStack s;
InitStack (&s);
while (N){
Push (&s,N%B);
N=N/B;
}
while (! StackEmpty(&s)){
i=Pop (&s);
printf ("%d'",i);
}
}
void main()
{
int N,B,i;
char ch = 'N';
i=1;
while (i){
printf ("请输入要转换的正整数");
scanf ("%d",&N);
if ((int)N!=N||N<=0)
printf ("请输入正整数!\n");
else
i=0;
}
i=1;
while (i){
printf ("请输转换的进制");
scanf ("%d",&B);
if ((int)B!=B||B<=1)
printf ("请输入大于的正整数!\n");
else
i = 0;
}
i = 1;
printf ("%d的%d进制为:",N,B);
MultiBaseOutput (N,B);
N=B=0;
}
这个中的'错误信息函数是什么意思'
望高手指点
最佳答案
- 二级知识专家网友:浪者不回头
- 2021-02-21 11:27
#include
#include
#include
#include
typedef int DataType;
typedef struct stacknode {
DataType data;
struct stacknode * next;
}StackNode;
typedef struct {
StackNode * top;
}LinkStack;
//错误信息
void Error(char * message)
{
printf ("Erroe:%s",message);
exit (1);
}
//初始化链栈
void InitStack (LinkStack * s)
{
s->top = NULL;
}
//判栈空
int StackEmpty (LinkStack * s)
{
return s->top == NULL;
}
//入栈
void Push (LinkStack * s , DataType x)
{
StackNode * p = (StackNode * ) malloc (sizeof(StackNode));
p->data = x;
p->next = s->top;
s->top = p;
}
//出栈
DataType Pop(LinkStack *s)
{
DataType x;
StackNode * p = s->top;
if ( StackEmpty (s))
Error ("下溢");
x = p->data;
s->top = p->next;
free (p);
return x;
}
//取栈顶
DataType StackTop (LinkStack* s)
{
if (StackEmpty (s))
// Error ("栈为空");
return s->top->data;
}
//数值转换
void MultiBaseOutput (int N,int B)
{
int i;
LinkStack s;
InitStack (&s);
while (N){
Push (&s,N%B);
N=N/B;
}
while (! StackEmpty(&s)){
i=Pop (&s);
printf ("%d'",i);
}
}
void main()
{
int N,B,i;
char ch = 'N';
i=1;
while (i){
printf ("请输入要转换的正整数");
scanf ("%d",&N);
if ((int)N!=N||N<=0)
{
printf ("请输入正整数!\n");
}
else
i=0;
}
i=1;
while (i){
printf ("请输转换的进制");
scanf ("%d",&B);
if ((int)B!=B||B<=1)
printf ("请输入大于的正整数!\n");
else
i = 0;
}
i = 1;
printf ("%d的%d进制为:",N,B);
MultiBaseOutput (N,B);
N=B=0;
}
ERROR那里没有函数类型
全部回答
- 1楼网友:晨与橙与城
- 2021-02-21 11:37
char 可以隐式转换为 ushort、int、uint、long、ulong、float、double 或 decimal。但是,不存在从其他类型到 char 类型的隐式转换。
system.char 类型提供几个处理 char 值的静态方法。
public static void main() {
char cha = 'a';
char ch1 = '1';
string str = "test string";
console.writeline(cha.compareto('b')); // output: "-1" (meaning 'a' is 1 less than 'b')
console.writeline(cha.equals('a')); // output: "true" console.writeline(char.getnumericvalue(ch1)); // output: "1"
console.writeline(char.iscontrol('\t')); // output: "true"
console.writeline(char.isdigit(ch1)); // output: "true"
console.writeline(char.isletter(',')); // output: "false"
console.writeline(char.islower('u')); // output: "true"
console.writeline(char.isnumber(ch1)); // output: "true"
console.writeline(char.ispunctuation('.')); // output: "true"
console.writeline(char.isseparator(str, 4)); // output: "true"
console.writeline(char.issymbol('+')); // output: "true"
console.writeline(char.iswhitespace(str, 4)); // output: "true"
console.writeline(char.parse("s")); // output: "s"
console.writeline(char.tolower('m')); // output: "m"
console.writeline('x'.tostring()); // output: "x"
}
以上都是char的一些常用的方法,可以用来判断输入的字符是否是数字或者字母,或者判断大小写都可以,我最新做的一个项目就用到了,希望对楼主有用,我是学c#的
我要举报
大家都在看
推荐资讯