鱼C论坛

 找回密码
 立即注册
查看: 2873|回复: 8

[已解决]这是大小写出问题了吗

[复制链接]
发表于 2021-10-4 11:31:31 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
#include<iostream>
#include<cstdlib>
#include<iomanip>
using namespace std;

#define OK 1
#define ERROR 0

typedef int Starus;
typedef int ElemType;

typedef struct LNode{
        ElemType data;
        struct LNode *next;
}LNode, *LinKlist;

ElemType survial;

Status InitList_CL(LinKlist &L){
           L=new LNode;
           L->next=L;
           L->data=0;
           return OK;
}

void CreateCL_Rear(LinKlist &L, int n){
int i;
LinKlist p,r;

if(n<1) return;
r=L;
cout<<"The sequence of n slaves:\n";
for(i=1;i<=n;i++){
    p=new LNode;
    p->data=i;
    cout<<setw(3)<<i<<" ";
    p->next=NULL;
    r->next=p;
    r=p;
    L->data++;
     }
     cout<<endl<<endl;
     r->next=L->next;
}

Status CLDelete(LinKlist &L,int m) {
  LinKlist p,q;
  int i;

  p=L->next;
  cout<<"The killed sequence of n slaves :\n";
  while(L->data>0){
    for(i=1;i<m-1;i++)
        p=p->next;

    cout<<setw(3)<<p->next->data<<" ";
    q=p->next;
    p->next=q->next;
    delete q;
    p=p->next;
    L->data--;
    if(L->data==1) survival=p->data;
  }
  cout<<endl<<endl;
  L->next=L;
  return OK;
}

int main(){
LinKlist L;
int Status_value,n=1,m=2;

do{
    cout<<"Please input the number n of slaves(must n>0):"<<endl;
    cin>>n;
}
while(n<1);

do{
    cout<<"\nPlease input the count m for kill slaves (must m>1) :"<<endl;
    cin>>m;
}while(m<2);
cout<<endl<<endl;

status_value=InitList_CL(L);
CreateCL_Rear(L,n);
status_value=CLDelete(L,m);
cout<<"\nThe survival of n slaves is the "<<survival<<"-th slave.\n\n";
system("pause");
return 0;
}
最佳答案
2021-10-4 11:43:47
拼写错误
多多检查下
#include<iostream>
#include<cstdlib>
#include<iomanip>
using namespace std;

#define OK 1
#define ERROR 0

typedef int Status; // 这里 
typedef int ElemType;

typedef struct LNode{
        ElemType data;
        struct LNode *next;
}LNode, *LinKlist;

ElemType survival; // 这里 

Status InitList_CL(LinKlist &L){
           L=new LNode;
           L->next=L;
           L->data=0;
           return OK;
}

void CreateCL_Rear(LinKlist &L, int n){
int i;
LinKlist p,r;

if(n<1) return;
r=L;
cout<<"The sequence of n slaves:\n";
for(i=1;i<=n;i++){
    p=new LNode;
    p->data=i;
    cout<<setw(3)<<i<<" ";
    p->next=NULL;
    r->next=p;
    r=p;
    L->data++;
     }
     cout<<endl<<endl;
     r->next=L->next;
}

Status CLDelete(LinKlist &L,int m) {
  LinKlist p,q;
  int i;

  p=L->next;
  cout<<"The killed sequence of n slaves :\n";
  while(L->data>0){
    for(i=1;i<m-1;i++)
        p=p->next;

    cout<<setw(3)<<p->next->data<<" ";
    q=p->next;
    p->next=q->next;
    delete q;
    p=p->next;
    L->data--;
    if(L->data==1) survival=p->data;
  }
  cout<<endl<<endl;
  L->next=L;
  return OK;
}

int main(){
LinKlist L;
int status_value,n=1,m=2; //这里 

do{
    cout<<"Please input the number n of slaves(must n>0):"<<endl;
    cin>>n;
}
while(n<1);

do{
    cout<<"\nPlease input the count m for kill slaves (must m>1) :"<<endl;
    cin>>m;
}while(m<2);
cout<<endl<<endl;

status_value=InitList_CL(L);
CreateCL_Rear(L,n);
status_value=CLDelete(L,m);
cout<<"\nThe survival of n slaves is the "<<survival<<"-th slave.\n\n";
system("pause");
return 0;
}
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2021-10-4 11:43:47 | 显示全部楼层    本楼为最佳答案   
拼写错误
多多检查下
#include<iostream>
#include<cstdlib>
#include<iomanip>
using namespace std;

#define OK 1
#define ERROR 0

typedef int Status; // 这里 
typedef int ElemType;

typedef struct LNode{
        ElemType data;
        struct LNode *next;
}LNode, *LinKlist;

ElemType survival; // 这里 

Status InitList_CL(LinKlist &L){
           L=new LNode;
           L->next=L;
           L->data=0;
           return OK;
}

void CreateCL_Rear(LinKlist &L, int n){
int i;
LinKlist p,r;

if(n<1) return;
r=L;
cout<<"The sequence of n slaves:\n";
for(i=1;i<=n;i++){
    p=new LNode;
    p->data=i;
    cout<<setw(3)<<i<<" ";
    p->next=NULL;
    r->next=p;
    r=p;
    L->data++;
     }
     cout<<endl<<endl;
     r->next=L->next;
}

Status CLDelete(LinKlist &L,int m) {
  LinKlist p,q;
  int i;

  p=L->next;
  cout<<"The killed sequence of n slaves :\n";
  while(L->data>0){
    for(i=1;i<m-1;i++)
        p=p->next;

    cout<<setw(3)<<p->next->data<<" ";
    q=p->next;
    p->next=q->next;
    delete q;
    p=p->next;
    L->data--;
    if(L->data==1) survival=p->data;
  }
  cout<<endl<<endl;
  L->next=L;
  return OK;
}

int main(){
LinKlist L;
int status_value,n=1,m=2; //这里 

do{
    cout<<"Please input the number n of slaves(must n>0):"<<endl;
    cin>>n;
}
while(n<1);

do{
    cout<<"\nPlease input the count m for kill slaves (must m>1) :"<<endl;
    cin>>m;
}while(m<2);
cout<<endl<<endl;

status_value=InitList_CL(L);
CreateCL_Rear(L,n);
status_value=CLDelete(L,m);
cout<<"\nThe survival of n slaves is the "<<survival<<"-th slave.\n\n";
system("pause");
return 0;
}
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-10-4 11:44:35 | 显示全部楼层
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2021-10-4 11:45:11 | 显示全部楼层
还有不认真的问题
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-10-4 12:30:02 From FishC Mobile | 显示全部楼层
人造人 发表于 2021-10-4 11:45
还有不认真的问题

孩子太菜了,呜呜呜
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-10-4 12:30:39 From FishC Mobile | 显示全部楼层
大马强 发表于 2021-10-4 11:43
拼写错误
多多检查下

谢谢
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-10-4 12:31:40 | 显示全部楼层
giegie666 发表于 2021-10-4 12:30
孩子太菜了,呜呜呜

认真一点呀,一个字母一个字母的检查代码,这种拼写错误你能检查不出来?怎么可能检查不出来?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-10-4 13:03:27 | 显示全部楼层
问题解决了,请设置【最佳答案】
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-10-4 13:03:28 | 显示全部楼层

习惯看报错信息,你就会知道了
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-7-5 00:25

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表