关于猪拉丁辅助功能的问题 [英] question about pig latin help for a subfunction

查看:70
本文介绍了关于猪拉丁辅助功能的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何处理下面的部分
我是新手,我无法完成createPiglatinVersion部分
谢谢
创建原始字符串的Pig Latin版本(对于整个输入行,可能是几个单词),然后保存在另一个字符串中-确保不要超出阵列边界,并且不要更改原始字符串细绳!确保将非字母复制到新的字符串,并将单词的猪拉丁版本代替输入的单词复制到新的字符串

这是我完成的工作

I have no idea about how to do the part below
I am a new learner and I could not finish createPiglatinVersion part
thanks
create a Pig Latin version of the original string (may be several words, for the whole line of input) and save in another string --MAKE SURE YOU DON''T GO OUTSIDE THE ARRAY BOUNDS, and DON''T CHANGE THE ORIGINAL STRING! Be sure to copy the non-letters to the new string, and copy the pig-latin versions of the words in place of an input word to the new string

Here is the work I have done

<code><pre lang="cs">#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#define FLUSH while (getchar() != ''\n'')

#define MAX_SIZE 256
#define WORD_SIZE 46

void getString (void);
void createPiglatinVersion(char *inputStr);
int getWord (char *inputStr,char *wordStr, int index);
void getPigLatin(char *temp, char *wordStr, int index);
bool isVowel(char oneword);
void printString(char *inputStr, char *outputStr);
bool repeatFcn(void);


int main (void)
{
    char oneword=''y'';
    printf("%d",isVowel(oneword));

    system("pause");
    return 0;
}

void getString (void)
{
     char inputStr[MAX_SIZE];

     printf("\nEnter a sentence (end with [Enter]):");
     fgets(inputStr, sizeof(inputStr), stdin);
     while (strlen(inputStr)>255)
          {
           FLUSH;
          }

}

void createPiglatinVersion(char *inputStr)
{
     char outputStr[MAX_SIZE];
     char temp[WORD_SIZE];
     char wordStr[WORD_SIZE];
     int index = 0;
     int i;

     for(i=0, i<MAX_SIZE, ++i)
          {
           outputStr
           getWord ( inputStr,wordStr, index);
           getPigLatin( temp,  wordStr, index);

          }
}

int getWord (char *inputStr,char *wordStr, int index)
{


     int i;
     for (i=0;i<WORD_SIZE&&isalpha(inputStr[index]);++i);
         {
          wordStr[i]=inputStr[index];
          index++;
          }
     wordStr[i]=''\0'';
     return index;
}

void getPigLatin(char *temp, char *wordStr, int index)
{
     if(isVowel(*wordStr)!=false&&isVowel(*wordStr+1))
         {
          strcpy(temp, wordStr);
          temp[strlen(temp)+1]=''\0'';
          strcat(temp,"ay");
          }
     else if(isVowel(*wordStr)!=false&& isVowel(*wordStr+1)!=false)
         {
          strcpy(temp,wordStr+2);//copy word starting from second character to temp
          temp[strlen(temp)]=*(--wordStr);//copy the first char of word to end of temp
          temp[strlen(temp)-1]=*(wordStr-2);
          temp[strlen(temp)+1]= ''\0''; // Null terminate temp
          strcat(temp,"AY");          // append "AY" to the string.
          }
     else if(isVowel(*wordStr))
         {
          strcpy(temp, wordStr);
          temp[strlen(temp)+1]=''\0'';
          strcat(temp,"way");
          }

}

bool isVowel(char oneword)
{
     oneword = toupper(oneword);
     return ((oneword==''A'' || oneword==''E'' || oneword==''I'' || oneword==''O'' || oneword==''U'')&&(oneword!=''Y''));
}


void printString(char *inputStr, char *outputStr)
{
     printf("The string you entered: %c\n", *inputStr);
     printf("The string converted to Pig Latin: %c\n", *outputStr);
}

bool repeatFcn(void)
{
     char check;

     printf("\nTry another? (y for yes): ");
     scanf(" %c", &check);
     if(check==''Y''||check==''y'')
         return true;
     else
         return false;
}


推荐答案

您不清楚您要问的是什么.尝试提出一个更具体的问题,并仅包括不起作用的零件的代码.这样,您就有可能获得更多答案. :)

祝你好运:thumbsup:
You are not making it clear what your question is. Try to ask a more specific question and include just the code for the part that is not working. That way you are likey to get more answers. :)

Good Luck :thumbsup:


这篇关于关于猪拉丁辅助功能的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆