鱼C论坛

 找回密码
 立即注册
查看: 3355|回复: 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
拼写错误
多多检查下
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<iomanip>
  4. using namespace std;

  5. #define OK 1
  6. #define ERROR 0

  7. typedef int Status; // 这里
  8. typedef int ElemType;

  9. typedef struct LNode{
  10.         ElemType data;
  11.         struct LNode *next;
  12. }LNode, *LinKlist;

  13. ElemType survival; // 这里

  14. Status InitList_CL(LinKlist &L){
  15.            L=new LNode;
  16.            L->next=L;
  17.            L->data=0;
  18.            return OK;
  19. }

  20. void CreateCL_Rear(LinKlist &L, int n){
  21. int i;
  22. LinKlist p,r;

  23. if(n<1) return;
  24. r=L;
  25. cout<<"The sequence of n slaves:\n";
  26. for(i=1;i<=n;i++){
  27.     p=new LNode;
  28.     p->data=i;
  29.     cout<<setw(3)<<i<<" ";
  30.     p->next=NULL;
  31.     r->next=p;
  32.     r=p;
  33.     L->data++;
  34.      }
  35.      cout<<endl<<endl;
  36.      r->next=L->next;
  37. }

  38. Status CLDelete(LinKlist &L,int m) {
  39.   LinKlist p,q;
  40.   int i;

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

  46.     cout<<setw(3)<<p->next->data<<" ";
  47.     q=p->next;
  48.     p->next=q->next;
  49.     delete q;
  50.     p=p->next;
  51.     L->data--;
  52.     if(L->data==1) survival=p->data;
  53.   }
  54.   cout<<endl<<endl;
  55.   L->next=L;
  56.   return OK;
  57. }

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

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

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

  71. status_value=InitList_CL(L);
  72. CreateCL_Rear(L,n);
  73. status_value=CLDelete(L,m);
  74. cout<<"\nThe survival of n slaves is the "<<survival<<"-th slave.\n\n";
  75. system("pause");
  76. return 0;
  77. }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

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

  5. #define OK 1
  6. #define ERROR 0

  7. typedef int Status; // 这里
  8. typedef int ElemType;

  9. typedef struct LNode{
  10.         ElemType data;
  11.         struct LNode *next;
  12. }LNode, *LinKlist;

  13. ElemType survival; // 这里

  14. Status InitList_CL(LinKlist &L){
  15.            L=new LNode;
  16.            L->next=L;
  17.            L->data=0;
  18.            return OK;
  19. }

  20. void CreateCL_Rear(LinKlist &L, int n){
  21. int i;
  22. LinKlist p,r;

  23. if(n<1) return;
  24. r=L;
  25. cout<<"The sequence of n slaves:\n";
  26. for(i=1;i<=n;i++){
  27.     p=new LNode;
  28.     p->data=i;
  29.     cout<<setw(3)<<i<<" ";
  30.     p->next=NULL;
  31.     r->next=p;
  32.     r=p;
  33.     L->data++;
  34.      }
  35.      cout<<endl<<endl;
  36.      r->next=L->next;
  37. }

  38. Status CLDelete(LinKlist &L,int m) {
  39.   LinKlist p,q;
  40.   int i;

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

  46.     cout<<setw(3)<<p->next->data<<" ";
  47.     q=p->next;
  48.     p->next=q->next;
  49.     delete q;
  50.     p=p->next;
  51.     L->data--;
  52.     if(L->data==1) survival=p->data;
  53.   }
  54.   cout<<endl<<endl;
  55.   L->next=L;
  56.   return OK;
  57. }

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

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

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

  71. status_value=InitList_CL(L);
  72. CreateCL_Rear(L,n);
  73. status_value=CLDelete(L,m);
  74. cout<<"\nThe survival of n slaves is the "<<survival<<"-th slave.\n\n";
  75. system("pause");
  76. return 0;
  77. }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-10-4 11:44:35 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-10-4 11:45:11 | 显示全部楼层
还有不认真的问题
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

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

孩子太菜了,呜呜呜
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

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

谢谢
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

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

认真一点呀,一个字母一个字母的检查代码,这种拼写错误你能检查不出来?怎么可能检查不出来?
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-10-4 13:03:27 | 显示全部楼层
问题解决了,请设置【最佳答案】
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

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

习惯看报错信息,你就会知道了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-5-12 16:38

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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