简体   繁体   English

有一个简单的问题。 不知道怎么解决,网上也没看到解决办法

[英]Having a simple issues. Don't know how to solve and I haven't seen any solutions online

These letters keep duplicating or changing one another:这些字母不断重复或更改:

|| a - u || e - y || w -c || v - b || x - d || z - f ||

I haven't been able to solve it by myself, or have seen a solution online.我自己无法解决,或者在网上看到了解决方案。

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <fstream>
#include <cstring>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
    char zodis[20];
    char zodis2[25];
    char h, ch;
    int l, i, ng, n, k, x;
do{
        cout << "\n\t\t ***** () Hangman () ***** \n\n\n\n";
        cout << "\t\t Enter a word : ";
        cin.get(zodis, 20);
        l=strlen(zodis); 
        char pasir[20]="0";
        n=0;k=0;
        system("CLS");

        for(i=0;i<=20;i++)
            {
        if (zodis[i]=='\0') {zodis2[i]='\0';break;}
        if (zodis[i]!=' ')  zodis2[i]='-'; 
        }
        ng=l+3;
    do{
        cia:
        if (k!=0)
        cout << "\n\n\t\t\t Chosen letters : " << pasir << "\n";
        cout << "\n\n\n\t\t\t      " << zodis2 << "\n\n\n Guesses left :  "<< ng << ", choose the next letter : ";
        cin >> ch; 
        system("CLS");
        for ( i=0;i<25;i++ )
        if ( pasir[i] == ch ) 
            {
     cout << "\t\t  Raide : " << ch << " : jau pasirinkote\n";
     goto cia;
     }
     ng--; pasir[k]=ch; pasir[k+1]=',';k+=2;

     for (i=0;i<=20;i++)
     if (zodis[i]==ch || zodis[i]==ch+20 || zodis[i]==ch-20) zodis2[i]=ch;
     if (!strcmp(zodis2,zodis))
        {
            system("CLS");
            cout << "\n\t\t\t      " << string(zodis) << "\n\n\t\t\t  Correct! :) \n" ; break;
            }
     }
    while(ng > 0 || !strcmp (zodis2,zodis));
    if (strcmp(zodis2,zodis))
        cout << "\n The word was : " << string(zodis) << endl;
        }
    while (ch==0);
    return 0;
}

Do you know how to use a debugger?你知道如何使用调试器吗? Probably time you learned.大概是你学会的时间。 Anyway反正

char zodis[20];
for(i=0;i<=20;i++)
    ... zodis[i] ...

Already that's an error, the valid indexes for zodis are 0 to 19, so zodis[20] is an out of bounds array access.这已经是一个错误, zodis的有效索引是 0 到 19,因此zodis[20]是越界数组访问。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Class 错误提示不知如何解决 - Class error message that I don't know how to solve 模型,视图,控制器 - 我理解类图,但我不了解所有线程问题。 建议吗? - Model, View, Controller - I understand the class diagram, but I don't understanding all the threading issues. Advice? C++:不知道如何解决坐标平面内比较坐标问题中的超时 - C++: I don't know how to solve the timeout in the problem of comparing coordinates in the coordinate plane 错误:out-of-line definition,不知道怎么解决 - Error : out-of-line definition , I don't know how to solve it 我不知道它如何工作表[+1]? - I don't know how it work table[+1]? 遇到分段错误:11.我看过其他帖子,但不知道如何在程序中添加内存 - Getting a Segmentation Fault: 11. I Have Seen Other Posts, but I Don't Know How I Can Add Memory to my Program 如何将 boost::any 类型转换为 std::array<int, size> 如果我不知道尺寸? - How to typecast boost::any to std::array<int, size> if I don't know the size? 在线评委:数组归一化,我不知道为什么我错了 - Online Judge:Array Normalization,I don't know why I am wrong 我只是想在我糟糕的代码中添加教程,我想要地方帮助,但我不知道该怎么做,知道吗? - I just wanted add tutorial in my poor code and I wanted place help but i don't know how to do it, any idea? 表达式必须具有 class 类型。 不知道怎么解决 - Expression must have class type. Don't know how to solve
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM