#include "stdio.h"
int a;
int m(int a)
{static int s; return (++s)+(--a);}
void main()
{int a=2;printf("%d",m(m(a)));}
这道题目的答案是3 可是我做不出来。
求以下程序输出结果的第一行 第二行。
#include "stdio.h"
void main()
{ int i=5;
do
{ switch(i%2)
{ case 0:i--;break;
case 1:i--;continue;
}
i--;printf("%d\n",i);
}while(i>0);
}
答案是2,0.
难道switch语句也有循环功能?
求输出结果的第一行 第二行 第三行
struct node
{char data;struct node *next;};
struct node *insert(struct node *h,char c)
{struct node *p,*p1,*p2;
p=(struct node*)malloc(sizeof(struct node));p->data=c;p->next=NULL;
if(h==NULL) h=p;
else
{p1=p2=h;
while(c>p1->data&p1->next!=NULL)
{p2=p1;p1=p1->next;}
if(c<=p1->data)
if(p1==h) {p->next=h;h=p;}
else {p1->next=p;p->next=p1;}
else {p1->next=p;}
}
return h;
}
struct node *del(struct node *h)
{struct node *p=h;
while(p!=NULL)
{if(p->data%2==0) p->next=p->next->next;
p=p->next;
}
return h;
}
void print (struct node *h)
{struct node *p=h;
while(p!=NULL)
{printf("%c",p->data);p=p->next;}
printf("\n");
}
void main()
{struct node *head=NULL;char *item="32659",*p=item;
puts(item);
while(*p)head=insert(head,*p++);
print(head);del(head);print(head);
}
答案是32659,23569,256
哪位大虾可以解释一下链表的函数是怎么个调用法的。如果嫌麻烦就用struct node *del(struct node *h)
这一段为例。
一下程序中有语法错误的是()
A fun(char aa[10])
{ while (*aa) printf("%c",*aa++);}
B fun(char *aa)
{ while (aa[0]) printf("%c",*aa++);}
C main()
{char *aa="hello!";}
{while (*aa) printf("%c",*aa++);}
D main()
{char aa[10]="hello!";}
{while (*aa) printf("%c",*aa++);}
答案是D请给出错误的原因。
另外是一些小的问题:
1,root(0)是什么作用啊 。
2。指针*P,与a[10],&a[10]的关系。这里的a[10]只是举的一个例子。
第三题的第十三行的p1应改为p2