最佳解答者
Three C++ problem

問題
解答
-
Do you really need to remove the character(s) in your program? You may choose to use an index to navigate through the characters in the variable "word" (by incrementing the index from 1 to the number of characters in the variable "word") instead of remove the character.
The issue you've mentioned in your post is the requirements from the assignment sheet. However, do you think of any algorithm in order to solve the problem?
2008年11月30日 16:36
所有回覆
-
Would you mind share your design/approach for the three problems? What exactly the technical issues you've got? I personally don't prefer to answer/provide code for an assignment from school.... sorry about that. However, if you've got questions/difficulties in your implementation, I think there are many friends here could give you some hints/solutions.2008年11月30日 15:24
-
Do you really need to remove the character(s) in your program? You may choose to use an index to navigate through the characters in the variable "word" (by incrementing the index from 1 to the number of characters in the variable "word") instead of remove the character.
The issue you've mentioned in your post is the requirements from the assignment sheet. However, do you think of any algorithm in order to solve the problem?
2008年11月30日 16:36 -
For your question 1a, the main technique you need to know is to navigate through a string/array of characters. If you know how to navigate through a string/array of characters, then it should be easy for you because you can extract each character from the input string and the string you need to compare, e.g. "ONE", "TWO", etc.
2008年11月30日 17:25 -
This is what i code so far.
Please tell me what should i put in.
#include
"stdafx.h"#include
<string.h>#include
<stdio.h>int
main (){
char str[15]; char result; char * digit[9] ={ "ONE", "TWO", "THREE", "FOUR" "FIVE" "SIX" "SEVEN" "EIGHT" "NIGHT"};
printf (
"Please enter a word",str);scanf (
"%s",&str);isdigitword(str);
return 0;}
int
isdigitword(char *word){
char * pch;pch=strchr(str, digit);
while (pch!=NULL){
printf (
"found at %d\n",pch-str+1);pch=strchr(pch+1);
}
return
1; /* change this to return 0 at leisure */}
2008年12月1日 11:30 -
Can someone tell me what wrong in the code please.
#include
"stdafx.h"#include
<string.h>#include
<stdio.h>bool
TextContainsADigit (char, char);int
main (){
char str[15]; char result; char * digit[9] ={ "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NIGHT"};
printf (
"Please enter a word");scanf (
"%s",&str); if(TextContainsADigit(str, digit){printf (digit[index - 1] );
}
else{printf (
"NO");}
return 0;}
bool
TextContainsADigit (char* text, char* digit){
while (*digit != 0){
if (*text != *digit){
text++;
}
else{
digit++;
text++;
}
if (*text == 0){
return false;}
}
return true;}
2008年12月1日 14:15