一道简单的数据结构题,环形链表问题,不知道哪里出了问题?

编程新人,请大神指教!
题目:

构造一个的环形双向链表,节点中存储的值为正整数,用这个链表进行删除操作。(链表中的元素均不超过232−1​)
Input

多行输入,从第一行开始,每行一个正整数代表链表中的元素,直到遇到−1,之后每行一个正整数x,代表要删除的元素,若删除的元素在链表中存在,则将链表中所有的x全部删去,若不存在,则输出-1,输入再次遇到−1结束,最后将链表中剩余的元素输出
Output

输出若干行,每行若干个整数
对于每个要删除的元素,若删除失败,输出-1,最后输出链表的剩余元素
Examples
Input

5
1
1
3
2
5
4
3
3
4
-1
3
2
6
-1

Output

-1
5 1 1 5 4 4

Note

删除成功时不需要给出任何信息
删除失败时输出 -1

只需在最后输出链表元素,空格分隔

我的代码:
#include
#include
#include
typedef struct node
{
int data;
struct node *qian,*hou;
} NODE;
int delete_cycle(NODE*head,int x)
{
NODE *p;
p=head->hou;
while((p->data!=x)&&(p!=head))
p=p->hou;
if(p==head) return -1;
else{
p->qian->hou=p->hou;
p->hou->qian=p->qian;
free(p);
return 0;}
}
int main()
{
int x;
NODE *head,*p,*q;
head=(NODE *)malloc(sizeof(NODE));//biaotou
scanf("%d",&x);
if(x!=-1)
{
q=(NODE *)malloc(sizeof(NODE));
q->data=x;
head->hou=q;
q->qian=head;
p=q;
}
else
{
head->data=-1;
head->hou=head;
head->qian=head;
}
getchar();
scanf("%d",&x);
while(x!=-1)
{
q=(NODE *)malloc(sizeof(NODE));
q->data=x;
p->hou=q;
q->qian=p;
p=q;
scanf("%d",&x);
}
//chuxian -1
p->hou=head;

//----------------------finished creating

int y,k;
scanf("%d",&y);
while(y!=-1)
    {
        k=delete_cycle(head,x);
        if(k==-1)
            printf("-1\n");
        scanf("%d",&y);
    }
NODE *pr;
pr=head->hou;
do
{
    printf("%d ",pr->data);
    pr=pr->hou;
}while(pr!=head);

}

目前问题是删除总是不成功,求大神指教!

2个回答

k=delete_cycle(head,y); //这里是y不是x

完整代码:

#include "stdio.h"
#include "stdlib.h"
#include "string.h"

typedef struct node
{
int data;
struct node *qian,*hou;
} NODE;
int delete_cycle(NODE*head,int x)
{
NODE *p;
p=head->hou;
while((p->data!=x)&&(p!=head))
p=p->hou;
if(p==head) return -1;
else{
p->qian->hou=p->hou;
p->hou->qian=p->qian;
free(p);
delete_cycle(head, x);
return 0;}
}
int main()
{
int x;
NODE *head,*p,*q;
head=(NODE *)malloc(sizeof(NODE));//biaotou
head->data = -1;
head->qian = head->hou = head;
while (true)
{
    scanf("%d",&x);
    if (x == -1) break;
    p =(NODE *)malloc(sizeof(NODE));
    p->hou = head;
    p->qian = head->qian;
    p->data = x;
    head->qian->hou = p;
    head->qian = p;
}

//----------------------finished creating

int y,k;
scanf("%d",&y);
while(y!=-1)
    {
        k=delete_cycle(head,y);
        if(k==-1)
            printf("-1\n");
        scanf("%d",&y);
    }
NODE *pr;
pr=head->hou;
do
{
    printf("%d ",pr->data);
    pr=pr->hou;
}while(pr!=head);
}

图片说明

在主函数里调用delete_cycle      时出错了,把x改成y
 k = delete_cycle(head, y);
还有就是delete_cycle  函数也有问题,你只删除了一个元素,题目要求删除所有相同的元素
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
不知道哪里出了问题?
在VC6编译时出现了一个‘warning’,可不知道哪里出了问题,代码是对的。rn因为我是用向导生成的Dialog程序。rn发现程序中有:rn#pragma warning (disable:4074)rn#pragma init_seg(lib)rn请问这是什么意思?rnrn警告信息:rninitializers put in library initialation arearnrn
不知道哪里出了问题
function insertHtml(HtmlCode)rnrn var win =window.doc_html.HtmlEdit.document;rn rn window.doc_html.HtmlEdit.focus();rn //win.selection.createRange().pasteHTML(HtmlCode);rn win.body.innerHTML=HtmlCode;rnrnrn我用这个函数时,用IE6。0浏览访问就很正常,在低版本的IE里就提示body不是对象,无法正常的调用此函数
一个简单的环形链表问题
和大家请教一下,每个节点只有一个指针域的环形链表如何实现双向的的查找操作。。。
不知道代码哪里出了问题
为什么在需要输入用户名的文本框中我让它为空,rn我认为运行时应该显示”用户名不能为空“,却显示“请输入正确的用户名”rnif cb_1.text="" thenrn MessageBox("提示","用户名不能为空")rn returnrnelseif cb_1.text<>'empire' thenrn MessageBox("提示","请输入正确的用户名")rn returnrnend if
硬盘不知道哪里出了问题??
我的硬盘大小为 15 GB ,我低格硬盘后在 CMOS 中检测仍为 15GB , 但用 Fdisk 进行分区时检测到确是 8 GB ,到底发生了什么事??其它空间哪里去了?rnrn我以前也对该硬盘进行过低格,但并没有出现过这样的问题,真是不解!!rnrn我用的低格软件是从 华军 那里下载的 叫 lformat
求救:不知道哪里出了问题?
我机子装的是win2000,但是奇怪的是,用ftp,或是播放声音和看片,都只能维持4,5分钟,然后就得重启才能继续几分钟。怎么办?装98的话,声卡驱程怎么装都不行。
搞不定了,不知道哪里出了问题???
rnCREATE procedure Sp_Combination_Insertrn(@MoreSelectTotal int,rn@SigleTotal int,rn@DisputeTotal int,rn@Title VarChar(100),rn@Createtime DateTime,rn@SigleSelectSubjectScore int,rn@MoreSelectSubjectScore int,rn@DisputeSubjectScore int)rnasrnrndeclare @Sigle varchar(8000)rndeclare @More varchar(8000)rndeclare @Dispute varchar(8000)rndeclare @strsql1 varchar(1000)rndeclare @strsql2 varchar(1000)rndeclare @strsql3 varchar(1000)rnrnrnrnrnset @strsql1='select @Sigle=isnull(@Sigle,'''') + rtrim(SigleSelectId) +'','' from (rnselect top '+ @SigleTotal +' SigleSelectId from SigleSelectSubjectrnorder by newid())a'rnexec (@strsql1)rnrnrnset @strsql2='select @More=isnull(@More,'''') + rtrim(MoreSelectId) +'','' from (rnselect top '+@MoreSelectTotal +' MoreSelectId from dbo.MoreSelectSubjectrnorder by newid())b'rnexec (@strsql2)rnrnrnset @strsql3='select @Dispute=isnull(@Dispute,'''') + rtrim(DisputeId) +'','' from (rnselect top' +@DisputeTotal+ ' DisputeId from dbo.DisputeSubjectrnorder by newid())c'rnexec (@strsql3)rnrnrnrninsert Combination ( Title,rn rn SigleSelectSubject ,rn MoreSelectSubject, rn DisputeSubject ,rn Createtime ,rn SigleSelectSubjectScore ,rn MoreSelectSubjectScore, rn DisputeSubjectScore rn )rnrnvalues (@Title,rn rn @Sigle ,rn @More, rn @Dispute ,rn @Createtime ,rn @SigleSelectSubjectScore ,rn @MoreSelectSubjectScore, rn @DisputeSubjectScore rn )rnrnGOrn
[表单提交]不知道哪里出了问题
软件里提交表单rnGET /login/newlogon.asp?userid=92994BFD16628E8B&pwd=pojie&rdata=036160 HTTP/1.1..Host: wwwwwwwww.crossun.com..Accept: */*..User-Agent: WhenStudio..Connection: close.rnrn返回结果是rnHTTP/1.1 400 Bad Request..Content-Type: text/html..Date: Sat, 20 May 2006 19:17:21 GMT..Connection: close..Content-Length: 39.... Bad Request (Invalid Hostname).rnrn但是rn在IE地址栏里输入wwwwwwwww.crossun.com/login/newlogon.asp?userid=92994BFD16628E8B&pwd=pojie&rdata=036160 rn却能返回正确信息(一个字符串)rnrn哪位高手知道是哪里出的问题?rnrnrnrn
一道简单的数据结构题 QDU
点击打开链接 栈中所保留元素均为 ‘(’ 如从左至右遍历数组 遇‘(’则入栈 遇‘)’则分情况讨论 1.栈空 则说明其左边再无‘(’可与其配对 由题意得 该‘)’无论和谁配对都需要转为‘(’ 因此通过num++来保留此次操作 2.栈非空 则说明其左边尚有‘(’可与其配对,则两者抵消 该‘)’不需入栈且栈顶的‘(’弹出 遍历结束 栈中所有元素均为原字符串中需要改变的‘(’ (包括1情况中由...
一道简单的数据结构题?
本人刚开始学习C数据结构,遇到一个小问题,请帮忙。rn/*用单链表遍一个学生成绩系统。具有查询成绩,修改成绩,删除成绩,添加 成绩全班平均*/rn#include rnrnstruct listrn int index;rn int number;rnrn int chinese,english,math;rn struct list *next;rn ;rn typedef struct list node;rn typedef node *link;rnint inquire(link head,int index)rn link pointer;rn pointer=head;rn while(pointer!=NULL)rn printf("Student scores\n");rn printf("%d ",index);rn printf(" School Number:%d\n",pointer->number);rn printf(" Chinese score:%d\n",pointer->chinese);rn printf(" English score:%d\n",pointer->english);rn printf(" Math score:%d\n",pointer->math);rn pointer=pointer->next;rn rnrn rnrnint modify(link head)rn link pointer;rn pointer=head;rn int chinese0,english0,math0;rn int index0;rn scanf("%d",index0);rn while(pointer!=NULL)rn if(pointer->index==index0)rnrn printf("========================================");rn printf("=1.Modify Number =");rn prinrf("=2.Modify Name =");rn prinrf("=3.Modify Chineae score =");rn prinrf("=4.Modify English score =");rn prinrf("=5.Modify Math score =");rn printf("========================================");rn printf("Please input your choose");rn int select;rn scanf("%d",select);rn switch(select)rn case 1: printf(" School Number:\n",number0);rn int number0;rn scanf("%d",number0);rn pointer->number=number0;rn break;rn case 2:rn break;rn case 3: printf(" Chinese score:\n",chinese0);rn int chinese0;rn scanf("%d",chinese0);rn pointer->chinese=chinese0;rn break;rn case 4: printf(" English score:\n",english0);rn int english;rn scanf("%d",english);rn pointer->english=english0;rn break;rn case 5: printf(" Math score:\n",math0);rn int math0;rn scanf("%d",math0);rn pointer->math=math0;rn break;rn rn pointer=pointer->next;rn rn rnrnrndelet(link head)rnlink pointer;rn link back;rn pointer=head;rn int index1;rn printf("Please input the student index you want to delete\n");rn scanf("%d",index1);rnrn while(pointer!=NULL)rn if(head.>next=index1)rn head=pointer->next;rn free(pointer);rn break; rnrn back=pointer;rn pointer=pointer->next;rn if(pointer->index=index1)rn back->next=pointer->next;rn free(pointer);rn rn rn return head;rnrn rnrnrnlink add(link head)rn link pointer;rn pointer=head;rn link new0;rnrn int index2=0;rn int number1;rn int chinese1,english1,math1;rn new0=(link)malloc(sizeof(node));rn while(pointer!=NULL)rn pointer=pointer->next;rn index2++rn new0->index=index2;rn printf("Please Input the data\n");rn printf("School Number\n");rn scanf("%d",number1);rn new0->number1;rn printf("Chinese\n");rn scanf("%d",chinese1)rn new0->chinese=chinese1;rn printf("English\n");rn scanf("%d",english1);rn new0->english=english1;rn printf("Math");rn scanf("%d",math1);rn new0->math=math1;rn pointer->next=new0->next;rn pointer->next=new0;rnrn rnrnrnlink average(head)rn link pointer;rn pointer=head;rn int sum,i,ave;rn i=0;rn sum=0;rn while(pointer!=NULL)rn sum=pointer.>chinese+pointer.>english+pointer.>math+sum;rn pointer=pointer->next;rn i++;rn rn ave=sum/i;rn printf("Score average Is:%d",ave);rnrn rnrnrnvoid main()rnrn link head;rn head=(link)malloc(sizeof(node));rn int selection;rnrn while(1)rn printf("========================================");rn printf("=Simple Student Score Management System=");rn prinrf("=1.inquire student score =");rn prinrf("=2.modify student score =");rn prinrf("=3.delete student score =");rn prinrf("=4.add student score =");rn prinrf("=5.student average score =");rn prinrf("=6.quit =");rn printf("========================================");rn printf("Please input your choose");rn scanf("%d",selection);rn switch(selection)rn case 1:inquire(head);rn break;rn case 2:modify(head);rn break;rn case 3:delet(head);rn break;rn case 4:add(head);rn break;rn case 5:average(head);rn break;rn case 6:rn exit(1);rn break;rn rn rnrn
每天一道leetcode141-环形链表
考试结束,班级平均分只拿到了年级第二,班主任于是问道:大家都知道世界第一高峰珠穆朗玛峰,有人知道世界第二高峰是什么吗?正当班主任要继续发话,只听到角落默默想起来一个声音:”乔戈里峰” 前言 2018.11.8号打卡明天的题目:https://leetcode-cn.com/problems/remove-nth-node-from-end-of-list/ 题目 每天一道leet...
表单对齐问题,不知道哪里出了问题
[code=html]rnrnrn Contact Formrn rn rnrnrn rn rn First Name:rn rn rn rn Last Name:rn rn rn rn E-mail:rn rn rn rn Phone:rn rn rn rn Comments:rn rn rn rn rn rn rnrnrn[/code]rn出来成了这样rn[img=https://img-bbs.csdn.net/upload/201611/04/1478252464_531048.png][/img]rn这段代码是截出来的,不知道问题在哪,求指导。
android的问题不知道哪里出了问题
关键代码:[code=java]rnprivate void Notific(ChatMsg msg) rn NotificationManager nm = (NotificationManager) contextrn .getSystemService(Context.NOTIFICATION_SERVICE);rn Notification n = new Notification(android.R.drawable.stat_notify_chat,rn msg.getText(), System.currentTimeMillis());rn n.flags = Notification.FLAG_AUTO_CANCEL;rn Intent i = new Intent(context, ChatActivity.class);rn Bundle notiextras = new Bundle();rn notiextras.putString("state", "initnoti");rn notiextras.putString("myname", myname);rn notiextras.putString("myid", myid);rn notiextras.putString("otherid", msg.getOtherid());rn notiextras.putString("myip", msg.getMyip());rn notiextras.putString("otherip", msg.getOtherip());rn notiextras.putString("date", msg.getDate());rn notiextras.putString("name", msg.getName());rn notiextras.putString("text", msg.getText());rn i.putExtras(notiextras);rn i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);rn PendingIntent contentIntent = PendingIntent.getActivity(context, 10, i, 0);rn n.setLatestEventInfo(context, "你来消息了!", msg.getText(), contentIntent);rn n.defaults = Notification.DEFAULT_VIBRATE | Notification.DEFAULT_ALL;rn nm.notify(100, n);rn Log.v("TextID", msg.getText());rn rnrnrnrnrnif(intent!=null)rn Log.v("extrasID", extras.toString()+""+myid);rn Log.v("extrasID", extras.getString("state")+extras.getString("name"));rn if(extras.getString("state").equals("initnoti"))rn ChatMsg msg = new ChatMsg(myip,rn otherip,rn extras.getString("name"),rn extras.getString("date"),rn extras.getString("text"),rn R.layout.example_list_say_he_item);rn list.add(msg);rn talkView.setAdapter(new ChatMsgViewAdapter(ChatActivity.this,list));rn Log.v("ID", extras.getString("otherip")+" "+msg.getOtherip()+" "+msg.getMyip());rn myip = msg.getMyip();rn otherip = msg.getOtherip();rn Log.v("ID", "initnoti"+" "+msg.getText()+" "+extras.getString("text"));rn rnrn[/code]rn第一次跳转时notiextras.putString("text", msg.getText());设的只是多少,Log.v("ID", "initnoti"+" "+msg.getText()+" "+extras.getString("text"));打印的就是多少,但是第二次时,Log.v("ID", "initnoti"+" "+msg.getText()+" "+extras.getString("text"));打印的还是第一次的值,为嘛啊
关于链表合并问题 不知道哪里出了问题
你好 rn这是我的代码rnrn```rn #include rn#include rn#include rntypedef struct Nodernrn int data;rn struct Node *next;rnNODE,*PNODE;rnvoid Delete(PNODE Head,int pos)rnrn int i=0;rn PNODE p=Head;rn while(p&&(inext;rn i++;rn rn if(p==NULL||i>pos-1)rn rn printf("错误\n");rn exit(-1);rn rn PNODE q=p->next;rn p->next=q->next;rn free(q);rn q=NULL;rnrnvoid insert(PNODE Head,int pos,int val)rnrn int i=0;rn PNODE p=Head;rn while((NULL!=p)&&(inext;rn i++;rn rn if(p==NULL||i>pos-1)rn rn exit(-1);rn rn PNODE q=(PNODE)malloc(sizeof(NODE));rn q->data=val;rn q->next=p->next;rn p->next=q;rnrnPNODE create(int a)rnrn int len;rn int i;rn int val;rn PNODE list;rn PNODE Head=(PNODE)malloc(sizeof(NODE));rn if(Head==NULL)rn rn printf("Memory allocation failure");rn exit(-1);rn rn elsern rn PNODE tail=Head;rn Head->next=NULL;rn printf("please input the length of list: ");rnrn for(i=0;idata=val;rn tail->next=p;rn p->next=NULL;rn tail=p;rnrn rn rnrn rn return Head;rnrnvoid print(PNODE Head)rnrn PNODE p;rn if(!Head->next)rn rn printf("the list is empty");rn exit(-1);rn rn p=Head->next;rn while(p)rn rn printf("%d\t",p->data);rn p=p->next;rnrn rn printf("\n");rnrnstruct Node* inter_link(struct Node* chain1,intrnrna,struct Node* chain2,int b)rnrn int temp;rn struct Node*head,*p1,*p2,*pos;rn if(a>=b)rn head=p1=chain1;rn p2=chain2;rn elsern head=p1=chain2;rn p2=chain1;rn temp=a;rn a=b;rn b=temp;rn rn pos=head;rn while(p2!=NULL)rn rn p1=p1->next;rn pos->next=p2;rn pos=p2;rn p2=p2->next;rn pos->next=p1;rn pos=p1;rn rn return head;rnrnvoid inversion(PNODE Head)rnrn PNODE p,q,pr;rn p=Head->next;rn q=NULL;rn Head->next=NULL;rn while(p)rn rn pr=p->next;rn p->next=q;rn q=p;rn p=pr;rn rn Head->next=q;rnrnvoid sort(struct Node *p,int m)rnrn int i,j,t;rn struct Node *k;rn k=p;rn for(i=0;idata>(p->next)->data)rn rn t=p->data;rn p->data=(p->next)->data;rn (p->next)->data=t;rn rn p=p->next;rn rn p=k;rn rnrnint main()rnrn PNODE Head,tab,boy;rn int a,b,h;rn scanf("%d",&a);rn Head=create(a);rnrn printf("this is the list:\n");rn print(Head);rn scanf("%d",&b);rn tab=create(b);rn print(tab);rn inversion(Head);rn printf("inverted list:\n");rn print(Head);rn printf("insert3:\n");rnrnrn Head=inter_link(Head,a,tab,b);rn print(Head);rn insert(Head,3,999);rn print(Head);rn h=a+b;rn Delete(Head,3);rn print(Head);rn //sort(boy,h);rn //print(boy);rnrnrnrn return 0;rnrnrn```rn为什么出现145368这个东西rn我的问题是 为什么会出现这串数字rn![图片说明](https://img-ask.csdn.net/upload/201708/19/1503131038_630352.png)rn
超级变态的问题,不知道哪里出了问题?
某个文件以前调试都正常,断点能正确到达,rn今天晚上改了几句代码就不行了,运行没问题,就是断点设置了停不下来,rn试试改动以前的文件,居然也不能正常断点调试了rn巨变态的是,其他的文件都可以正常调试,就这个文件不行。rnrn重新把系统还原了,问题还没解决,5555555555555555rnrn都快4:00了,还没得睡觉,高手快来啊!!!rnrn救救可怜的我吧……
简单的链表不知道错在哪里
就是实现动态输入一些数,然后再输出来,每次只能输出链表最后一个数据!rn#includern#includerntypedef struct nodernrn int data;rn node* next;rnnode;rnnode*create()rnrn int i=0;rn node *p,*q,*head;rn int x=0;rn head=(node*)malloc(sizeof(node));rnrn while(1)rn rn printf("Please input a data!\n");rn scanf("%d",&x);rn if(x==0) break;rn rn p=(node*)malloc(sizeof(node));rn p->data=x;rn if(++i=1)rn rn head->next=p;rn rn elsern rn q->next=p;rn rn q=p;rn rn q->next=NULL;rn return head;rnrnvoid print(node *head)rnrn node *p;rn int index=0;rn if(head->next==NULL)rn rn printf("empty");rn return;rn rn p=head->next;rn while(p!=NULL)rn rn printf("the %dth node is %d\n",++index,p->data);rn p=p->next;rn rnrnvoid main()rnrn node *head=create();rn print(head);rnrnrn
环形链表约瑟夫问题
思想: 新编号(一定是1)推旧编号 公式1:【长度为i的链表编号与报数的关系】 编号=(报数m-1)%长度i+1 公式2:【新编号(长度i-1)与旧编号(长度i)之间的关系】 旧编号=(新编号-1+弹出编号s)%长度i+1 联合推出: 旧编号=(新编号+报数m-1)%长度i+1 公式1的推导 公式2的推导: 代码: def live(head,m): if not head or h...
leetcode(简单):环形链表
今天,我又来了啊,继续刷leetcode,上瘾不上火,哈哈哈。 题目: 给定一个链表,判断链表中是否有环。 为了表示给定链表中的环,我们使用整数pos来表示链表尾连接到链表中的位置(索引从 0 开始)。 如果pos是-1,则在该链表中没有环。 示例 1: 输入:head = [3,2,0,-4], pos = 1 输出:true 解释:链表中有一个环,其尾部连接到第二个...
简单的问题,可我不知道哪出了问题!
下面的程序就是让BL中的值以16进制显示出来,可调试的结果不正确,请大虾帮帮忙! 谢谢先!rn C_SEG SEGMENTrn ASSUME CS:C_SEGrn START: MOV AL,16 rn MOV BL,ALrn MOV CL,4rn SHR BL,CLrn AND BL,0FHrn CMP BL,09Hrn JLE L1rn ADD BL,07Hrn L1: ADD BL,30Hrn MOV DL,BLrn MOV AH,02Hrn INT 21Hrn MOV AH,0rn AND AL,0FHrn CMP AL,09Hrn JLE L2rn ADD AL,07Hrn L2: ADD AL,30Hrn MOV DL,ALrn MOV AH,02Hrn INT 21Hrn MOV DL,'H'rn INT 21Hrn MOV AH,4CHrn INT 21Hrn C_SEG ENDSrn END START
c++快速排序 不知道哪里出了问题
includeusing namespace std;void fun(int a[],int low,int high) int i,j,key,change; i=low; j=high; key=a[low]; while(ikey) j--; if(i>n; for(int h=0;h>a[h]; fun(a,0,n-1); for(int g=0;g
不知道哪里出了问题,请高手指点
不知道哪里出了问题,请高手指点rnSub Macro1()rn Dim copy As Stringrn rn For i = 2 To 1500rn rn Cells(A, i).Selectrn copy = Selection.copy.Valuern Windows("Location.xls").Activatern Cells.Find(What:="copy.").Activatern Selection.copyrn Windows("information_20080603.xls").Activatern Cells(f, i).Selectrn ActiveSheet.Pastern Selection.Value = copyrn rn Nextrn rnEnd Subrnrn
c++快速排序 不知道是哪里出了问题 ....
#includernusing namespace std;rnvoid fun(int a[],int low,int high)rnrn int i,j,key,change;rn i=low;rn j=high;rn key=a[(low+high)/2];rnrn while(ikey)rn --j;rn if(i>=j)rn break;rn if(i>n;rn for(int h=0;h>a[h];rnrn fun(a,0,n-1);rn for(int g=0;g
交替字符串 不知道哪里出了问题 QAQ
[code=c]#include rn#include rn#include rnusing namespace std;rnclass HelloWord rnpublic:rn static string getInfo(string str)rn rn string str1, str2, str3;rn bool bl = false;rn cin >> str1;rn cin >> str2;rn cin >> str3;rn int s1 = str1.size(), s2 = str2.size(), s3 = str3.size();rn int i = 0, x = 0, y = 0;rn if (s1 + s2 == s3 && (s1!=0 || s2!=0))rn rn for (; i != s3; i++)rn rn if (str3[i] == str1[x])rn rn x++;rn bl = true;rn rn else if (str3[i] == str2[y])rn rn y++;rn bl = true;rn rn elsern rn bl = false;rn str = "NO";rn break;rn rn rn if (bl)rn rn str = "YES";rn rn rn elsern rn str = "NO";rn rn return str;rn rn;rnint main()rnrn string c = HelloWord::getInfo("Hello World");rn cout << c << endl;rn[/code]
数据库不知道哪里出了问题,急~~~请教~~
select distinct a.REPORT_TIME,a.FRA05,b.area_name,from rnTB_JP_JA2001_DATA a,t_area b where a.FRA05 = b.area_code and (FRA05 like ('43%') and A12='1' or DWBS='10' rngroup by a.REPORT_TIME,a.FRA05,b.area_namernrn这条语句前两天还可以用,今天突然不能用了rnrn发现 不用or或者不用group by就可以用,rn再或者只从一个表里取数据也可以用,rn但和在一起就不能用了rnrn不知道哪里出了问题,请教~~rn
思考了很久,不知道是哪里出了问题。
表student1rngonghao xingmingrnx001 江泽民rnx002 毛泽东rnx003 周恩来rnx004 刘少奇rnx005 何小华rnx006 刘德华rnx007 李日怀rnrn表student2rnx005 胡祥鸿 广州一中rnx002 张金水 上海中大rnx003 黄玉保 南京大学rnrn执行以下语句:(为什么表student1无法更新?????谢谢)rnrnupdate student1 set xingming=(select XM from student2 where student2.gonghao=student1.gonghao)rnrnrn
不知道这个程序是哪里出了问题
#includern#includernvoid main()rnrn char *str1[20],*str2[20],*str3[20];rn char swap();rn printf("Input three lines:\n");rn gets(str1);rn gets(str2);rn gets(str3);rn if(strcmp(str1,str2)>0)swap(str1,str2);rn if(strcmp(str1,str3)>0)swap(str1,str3);rn if(strcmp(str2,str3)>0)swap(str2,str3);rn printf("Now,the order is:\n");rn printf("%s\n%s\n%s\n",str1,str2,str3);rnrnrnchar swap(char *p1,char *p2)rnrn char *p[20];rn strcpy(p,p1);strcpy(p1,p2);strcpy(p2,p);rn
不知道哪里出了问题,请高手帮忙!
事件查看器/系统/错误rnrn利用 DefaultLaunchPermssion 启动 DCOM 服务器的访问被拒绝。 服务器是: rn00020906-0000-0000-C000-000000000046rn用户是 Unavailable/Unavailable, SID=Unavailable.rnrn大概几秒钟就有一条,过不了多长时间就满了,怎么办?谁能解答?谢谢了。
我的sybase不知道哪里出了问题?
我的数据库是建在服务器端的sybase上的,然后我在另一台win2000的机器上也安装了sybase,作为客户端,rn 我用win2000的sybase center for java(已经用补丁覆盖了,可以正常操作)来建库,我建了17个表后,不知道怎么回事,再建表,但保存时,就死在那了。我把sybase服务器重新启动,在建第18个表,然后保存。我看到服务器的sybase.log出现这样的提示:rn(1)server Space available in the log segment has fallen critically low in database 'Tianhe'. All future modifications to this database will be suspended until the log is successfully dumped and space becomes available.rn(2)server 1 task(s) are sleeping waiting for space to become available in the log segment for database Tianhe.rn(3)server 1 task(s) are sleeping waiting for space to become available in the log segment for database Tianhe.rn(4)server 1 task(s) are sleeping waiting for space to become available in the log segment for database Tianhe.rn(5)kernel Cannot send, host process disconnected: spid: 10rn(6)Error: 1608, Severity: 18, State: 4rn(7)server A client process exited abnormally, or a network error was encountered. Unless other errors occurred, continue processing normally.rn(8)server Error: 2812, Severity: 16, State: 5rn(9)server Stored procedure 'sp_thresholdaction' not found. Specify owner.objectname or use sp_help to check whether the object exists (sp_help may produce lots of output).rnrn 而win2000的sybase center java editor的dos控制台,在我打开“tianhe”这个数据库是就抛了以下这些信息,这是我还没有开始建立第18个表。rn rn java.lang.NumberFormatException: 12.5.0.1rn at java.lang.Double.valueOf(Double.java:121)rn at sybase.scp.ase.so.ASConnection.getServerVersion(ASConnection.java:866rn)rn at sybase.scp.ase.so.DatabaseRSO.open(DatabaseRSO.java:177)rn at sybase.scf.so.VSOBaseContainer.open(VSOBaseContainer.java)rn at sybase.scp.ase.bo.DatabaseBO.Open(Compiled Code)rn at sybase.scf.bo.sctBaseContainer.onOpen(sctBaseContainer.java)rn at sybase.scf.jviewer.ScjTreeView.openContainer(Compiled Code)rn at sybase.scf.jviewer.ScjTreeView.treeExpanded(ScjTreeView.java)rn at javax.swing.JTree.fireTreeExpanded(Compiled Code)rn at javax.swing.JTree.setExpandedState(Compiled Code)rn at javax.swing.JTree.expandPath(JTree.java:1467)rn at javax.swing.plaf.basic.BasicTreeUI.toggleExpandState(BasicTreeUI.javarn:1910)rn at javax.swing.plaf.basic.BasicTreeUI.handleExpandControlClick(BasicTreernUI.java:1897)rn at javax.swing.plaf.basic.BasicTreeUI.checkForClickInExpandControl(BasicrnTreeUI.java:1858)rn at javax.swing.plaf.basic.BasicTreeUI$MouseHandler.mousePressed(BasicTrerneUI.java:2540)rn at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:21rn8)rn at java.awt.Component.processMouseEvent(Compiled Code)rn at java.awt.Component.processEvent(Compiled Code)rn at java.awt.Container.processEvent(Compiled Code)rn at java.awt.Component.dispatchEventImpl(Compiled Code)rn at java.awt.Container.dispatchEventImpl(Compiled Code)rn at java.awt.Component.dispatchEvent(Compiled Code)rn at java.awt.LightweightDispatcher.retargetMouseEvent(Compiled Code)rn at java.awt.LightweightDispatcher.processMouseEvent(Compiled Code)rn at java.awt.LightweightDispatcher.dispatchEvent(Compiled Code)rn at java.awt.Container.dispatchEventImpl(Compiled Code)rn at java.awt.Window.dispatchEventImpl(Compiled Code)rn at java.awt.Component.dispatchEvent(Compiled Code)rn at java.awt.EventDispatchThread.run(Compiled Code)rnrnrn 请问这是怎么回事呢?rn服务器端的sybase server的配置如下:rntype = 1rnserver_name = sybasernserver_page_size = 2krnmaster_device_physical_name = /dev/sdb2rnmaster_device_size = 517rnmaster_database_size = 200rnsybsystemprocs_device_physical_name = /dev/sdb3rnsybsystemprocs_device_size = 133rnsybsystemprocs_database_size = 133rnerrorlog = /opt/sybase-12.5/ASE/install/sybase.logrnconfigfile = /opt/sybase-12.5/ASE/sybase.cfgrnsybsystemdb_device_physical_name = /opt/sybase-12.5/data/sybsystemdb.datrnsybsystemdb_device_size = 25rnsybsystemdb_database_size = 25rnshmem = /opt/sybase-12.5/ASErndefault_backup_server = sybase_backrnrn
不知道哪里出了问题,望指点啊~~~
左边导航切换时右边的内容会显示会出错。不知道那里错了,望指点!!先谢谢了~rn代码如下:rnrnrn rn new document rn rn rn rn rn rn rn rn rn rnrn rn rn rn rn Baidurn Googlern Sinarn rn rn rn rn </div>rn </div>rn </body> rn</html>
变量溢出,不知道哪里出了问题
long long lcm_naive(int a, int b) rn long long lcm = a * b;rn return lcm;rnrnrnint main() rn int a, b;rn std::cin >> a >> b;rn std::cout << lcm_naive(a, b) << std::endl;rn return 0;rnrnrninput:rn28851538 1183019rnoutput应该是34131917633222rn没超出long long的范围,但返回值是-187468090rn将long long换成unsigned long long返回值是unsigned long long的最大值18446744073709551615 这个数....rnrnrn不知道哪里出问题了,求指点。。。。
数据库写入错误,不知道哪里出了问题!
dim article_title,article_content,article_class,article_author,IncludePic,article_image,article_keyrnarticle_class=trim(request("article_class"))rnarticle_title=trim(request("title"))rnarticle_content=Server.HTMLEncode(request("content"))rnIncludePic=trim(request("IncludePic"))rnarticle_author=trim(request("author"))rnarticle_image=trim(request("DefaultPicUrl"))rnarticle_key=trim(request("key"))rnrnset rs=server.createobject("adodb.recordset")rnsql="select * from article"rnrs.open sql,conn,1,3rnrs.addnewrnrs("article_class")=article_classrnrs("article_title")=article_titlernrs("article_content")=article_contentrnif IncludePic="yes"thenrnrs("article_pic_or")=1 rnif article_image<>"" thenrnrs("article_image")=article_imagernend ifrnelse rs("article_pic_or")=0rnend ifrnrs("article_author")=article_authorrnrs.updaternrs.closernset rs=nothingrnResponse.Write" "rnrn表单中的内容我看都没有错,主体内容我用的编辑器,应该没有错误,就是提示‘update’有错!rn
求助,不知道下面的程序哪里出了问题
题目如下rnB. 世界杯rnTime limit: 1000 msrnrnMemory limit: 256 MBrnrnStandard I/Ornrn世界杯中小组赛的赛制是极有意思的,有时,一个队离小组出线,只有1球之差。下面介绍世界杯足球赛小组赛规则:rnrn世界杯小组赛每小组共4支球队,计它们为1,2,3,4。小组内任意两支球队之间要进行一场比赛,共进行6场比赛(对于每1支球队,要打3场比赛)。一场比赛下来,获胜的球队将获得3分,失败的球队获得0分,若双方打平,则各得1分。6场比赛结束后,4支球队按如下方式排名:rnrn1、积分多的球队排在前面。rnrn2、若积分相同,则净胜球(该队打的3场比赛的进球数减去失球数)多的队排前面。rnrn3、若还相同,则进球数多的队排前面。rnrn4、还是相同的情况保证数据不可能出现。rnrn排名前两位的球队出线。rnrn善于思考的小C想编一个程序,输入某一小组的所有比赛结果,输出某些数据。详见后文。rnrnrnInput Descriptionrn每场比赛的结果,共六行,每行一场比赛,格式为,球队A:球队B。顺序如下:rnrn球队1:球队2rnrn球队3:球队4rnrn球队1:球队3rnrn球队4:球队2rnrn球队2:球队3rnrn球队4:球队1rnrnrnOutput Descriptionrn有4行,其中第i行表示球队i的基本信息,它们分别为:rnrn排名 积分 净胜球(必须标正负号,0也标正号) 进球 失球 是否出线(Y或N)rnrnrnSamplernINPUT rnrn1:1rn0:0rn0:3rn0:2rn0:1rn1:2rnOUTPUT rnrn3 4 -2 3 5 Nrn2 4 +1 3 2 Yrn1 7 +4 4 0 Yrn4 1 -3 1 4 NrnHintrn1、样例来自于2010年南非世界杯A组。球队1,2,3,4非别为:南非,墨西哥,乌拉圭和法国。比赛结果为:rnrn南非1:1墨西哥 乌拉圭0:0法国rnrn南非0:3乌拉圭 法国0:2墨西哥rnrn墨西哥0:1乌拉圭 法国1:2南非rnrn2、测试数据绝大部分来自于历年世界杯的真实数据,每一项输入输出数据的绝对值均小于等于20。rnrn程序如下:rn#include rn#include rnrnvoid calculate(int* team_one, int* team_two, char* score,int length);rnrnrnint main()rnrn int team[4][6]=0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,4;rn //0 points 1 goal 2 goal_difference 3 rankrnrn char score[5];rn int length;rn scanf("%s",score);rn length=(int)strlen(score);rn calculate(team[0],team[1],score,length);rn scanf("%s",score);rn length=(int)strlen(score);rn calculate(team[2],team[3],score,length);rn scanf("%s",score);rn length=(int)strlen(score);rn calculate(team[0],team[2],score,length);rn scanf("%s",score);rn length=(int)strlen(score);rn calculate(team[3],team[1],score,length);rn scanf("%s",score);rn length=(int)strlen(score);rn calculate(team[1],team[2],score,length);rn scanf("%s",score);rn length=(int)strlen(score);rn calculate(team[3],team[0],score,length);rnrnrnrn for(int i=0; i<4; i++)rn rn team[i][5]=team[i][0]*10000+10000+6000+team[i][2]*100+team[i][1];rn rn for(int i=1; i<4; i++)rn rn for(int k=0; k=team[k][5])rn rn team[i][3]=k+1;rn for(int m=i; m>k; m--)rn rn team[m-1][3]+=1;rn rn rn k=i;rn rn rnrnrnrn for(int i=0; i<4; i++)rn rn if(team[i][3]<=2)rn rn team[i][4]=89;rn rn elsern rn team[i][4]=78;rn rn rn for(int i=0; i<4; i++)rn rn if(team[i][2]>=0)rn rn printf("%d %d +%d %d %d %c\n",team[i][3],team[i][0],team[i][2],team[i][1],team[i][1]-team[i][2],team[i][4]);rn rn elsern rn printf("%d %d %d %d %d %c\n",team[i][3],team[i][0],team[i][2],team[i][1],team[i][1]-team[i][2],team[i][4]);rn rn rnrnrnrnvoid calculate(int* team_one, int* team_two, char* score,int length)rnrn int _score[2];rn memset(_score,0,sizeof(_score));rn int i=0;rn while(score[i]!=':')rn rn _score[0]=_score[0]*10;rn _score[0]=_score[0]+score[i]-'0';rn i++;rn rn i+=1;rn for(;i_score[1])rn rn team_one[0]+=3;rn rn else if(_score[0]<_score[1])rn rn team_two[0]+=3;rn rn else if(_score[0]==_score[1])rn rn team_one[0]+=1;rn team_two[0]+=1;rn rnrn
qduoj 一道简单的数据结构题(水题)
题目链接:https://qduoj.com/problem/147/点击打开链接 一道简单的数据结构题 发布时间: 2017年6月3日 18:46   最后更新: 2017年6月3日 18:51   时间限制: 1000ms   内存限制: 128M 描述 如果插入“+”和“1”到一个括号序列,我们能得到一个正确的数学表达式,我们就认为这个括号序列是合法的。例
一道数据结构题
反链表的伪代码
简单的PWM,控制电机加速。不知道哪里出了问题。
#includern#define uint unsigned intrn#define uchar unsigned charrn rnuint i=0;rnuint PWM=0; rnvoid Timer1_Init(); // T1 rnvoid Timer0_Init(); //rnvoid main()rnrn //P1=0xFF;rn rn TMOD=0X11; // rn EA=1;rn Timer1_Init();rn Timer0_Init();rn while(1); rn rnrnrnrnvoid Timer1_Int() interrupt 3rnrn TH1=0XD8;rn TL1=0XEF;rn P1=0xFF;rn TH0=(65535-PWM)/256 ;rn TL0=(65535-PWM)%256 ;rn TR0=1;rnrn rnrnvoid Timer0_Int() interrupt 1rnrn rn P1=0X00;rn TR0=0;rn PWM=PWM+20;rn if(PWM==10000)rn PWM=0;rnrnvoid Timer1_Init()rnrn TH1=0XD8;rn TL1=0XEF;rn ET1=1;rn TR1=1;rnrnrnvoid Timer0_Init()rnrn TH0=(65535-PWM)/256;rn TL0=(65535-PWM)%256 ;rn ET0=1;rnrn
简单问题 不知道错哪里
TStream * TemplateStream=new TStream();rnImage3->Picture->Bitmap->SaveToStream(TemplateStream);rnImage4->Picture->Bitmap->LoadFromStream(TemplateStreamrnrn看看上面有什么错误
一道简单的大数相加题 不知道错在哪里……
[color=#FF0000]A + B Problem IIrnTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)rnTotal Submission(s): 13818 Accepted Submission(s): 2368rnrnrnProblem DescriptionrnI have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.rnrn rnrnInputrnThe first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers, A and B. Notice that the integers are very large, that means you should not process them by using 32-bit integer. You may assume the length of each integer will not exceed 1000.rnrn rnrnOutputrnFor each test case, you should output two lines. The first line is "Case #:", # means the number of the test case. The second line is the an equation "A + B = Sum", Sum means the result of A + B. Note there are some spaces int the equation. Output a blank line between two test cases.rnrn rnrnSample Inputrn2rn1 2rn112233445566778899 998877665544332211rn rnrnSample OutputrnCase 1:rn1 + 2 = 3rnrnCase 2:rn112233445566778899 + 998877665544332211 = 1111111111111111110[/color]rnrnrn#include rn#include rnrnusing namespace std;rnrn#define SIZE 1000rnchar s[21][SIZE],ss[21][SIZE];rnchar s1[21][SIZE],s2[21][SIZE],sum[21][SIZE];rnint i,j,k,c,t,cnt,ct,len,m;rnrnint main()rnrn cin>>cnt;rn rn for(ct=0;ctstrlen(s2[ct])) len = strlen(s1[ct]);rn else len = strlen(s2[ct]);rn rn for(i=0;i=0;--i)rn printf("%d",s1[ct][i]);rn cout<<" + ";rn for(i=strlen(s2[ct])-1;i>=0;--i)rn printf("%d",s2[ct][i]);rn cout<<" = ";rn rn j=SIZE;rn while(!sum[ct][j]) --j;rn for(i=j;i>=0;--i)rn printf("%d",sum[ct][i]);rn cout<
Java环形链表--约瑟夫问题
n个小孩围成圈,丢手帕,从第start个小孩开始丢,每到第step个小孩出局;接着从下一个小孩开始,直到最后一个小孩为止,游戏结束。/** * @author Jiaozl * CycLink cyclink = new CycLink(); * cyclink.setLen(5); * cyclink.createLink(); * cyclink.setStart(2); *
环形链表,约瑟夫问题,(7)
一个经典的环形链表问题,有1,2,3,,,,n这些数字排成一个圆圈,从1开始每次删除第m个数字,求出这个圆圈中最后的数字。当然也可以说先从数字k开始,数到m删除这个数字,然后就从1开始,数到m删除这个数字,原理是一样。 这里是从1开始,数到m删除这个数字。 其实一个单向非循环链表也是可以模拟这个应用的,就是当指针知道最后一个节点时,让他转到头结点继续遍历。 下面的实例是环形链表,尾节点的下一
环形链表+约瑟夫问题实现
1.问题描述: 约瑟夫问题: 已知m个人还坐在桌子上,从第k个人开始进行报数,报道第n个人出列,直达所有的额人都出列为止,求出出列的顺序 2。数据结构: 我们根据题意可以明显的发现,如果我们用环形链表来进行处理的话每次出队一人是非常好实现的,我们判断终点的条件就是环形链表内的权值为0 在这里没什么好说的,我们只要注意一点就好了,有的书上并没有说明,但是当约瑟夫问题的头节点被删除之后,我们
相关热词 c#检测非法字符 c#双屏截图 c#中怎么关闭线程 c# 显示服务器上的图片 api嵌入窗口 c# c# 控制网页 c# encrypt c#微信网页版登录 c# login 居中 c# 考试软件