Family%%Given%Phone
Simpson%%Homer%%555-1234
Gumble%%Barney%%555-9876
then the output should look like this (the ‘G’ of ‘Given’ is in column 9 and the ‘P’ of ‘Phone’ is in column 17)
Family>>Given>>>Phone
Simpson>Homer>>>555-1234
Gumble>>Barney>>555-9876
哪位高手可以帮忙解答下...
----------------解决方案--------------------------------------------------------
希望翻译一下
----------------解决方案--------------------------------------------------------
长度不足8的用'>'来对齐嘛
什么符号打不出来??打不出来那还怎么输入?
----------------解决方案--------------------------------------------------------
#include <iostream.h>
#define MAX_LEN 256
#define MAX_NUM 100
#define MAX_WORD_LEN 8 //假定单词字母数字都是小于等于8的,多的没考虑!
int nCount = 0;
void SliptToWord(char *p,char **ret)
{
char *q = p;
int i = 0;
int j = 0;
while(q[i])
{
for(;!(((q[i]=='%')&&(q[i+1]=='%'))||q[i]=='\0');i++); //这边要看清楚
if(q[i] == '%')
{
q[i] = '\0';
ret[j++] = q;
q = &q[i+2];
nCount++;
i = 0;
}
else if(q[i] == '\0')
{
ret[j++] = q;
nCount++;
}
}
}
int main()
{
char *p = new char[MAX_LEN];
cin>>p;
char *ret[MAX_NUM];
for(int i = 0;i<MAX_NUM;i++)
{
ret[i] = new char[MAX_WORD_LEN];
}
SliptToWord(p,ret);
int nWordLen = 0;
for(int i = 0;i<nCount;i++)
{
cout<<ret[i];
nWordLen = strlen(ret[i]);
for(int j = 0;j<MAX_WORD_LEN-nWordLen;j++)
{
cout<<'>';
}
}
delete [] *ret;
return 0;
}
[此贴子已经被作者于2007-8-17 10:32:07编辑过]
----------------解决方案--------------------------------------------------------
就是说用一个或者多个">"字符来代替tab字符.简单点说就是跟在tab字符后面的字母要出现在第9行.第17行。第35行...
楼上的。有这么复杂吗??
----------------解决方案--------------------------------------------------------
就是说用一个或者多个">"字符来代替tab字符.简单点说就是跟在tab字符后面的字母要出现在第9行.第17行。第35行...
楼上的。有这么复杂吗??
还有,你是来请教的还是来消遣的?稍微谦虚一点。。。
----------------解决方案--------------------------------------------------------
晕.你完全误解我的意思了..我只是觉得应该不会很复杂..因为我做了第一个.
copies each character from standard input directly to standard output, except that each space is replaced by a tilde (‘~’).if the input looks like this
The quick brown fox jumps
over the lazy dog.
then the output should look like this
The~quick~brown~fox~jumps
over~the~lazy~dog.
The program should continually process input until it reaches end-of-file. The core of the program will be a loop with the following structure:
while (get a character from stdin and test for end-of-file) {
put the character (or its replacement) to stdout
}
第二个应该只需要在这个基础上修改下便可,所以我觉得应该没那么复杂的..你看看第一个.
----------------解决方案--------------------------------------------------------
看了,那是完全不一样的题目!
如果用String来做的话,这题只要一条语句就可以完成了!
str.replace(\" \",\"~\"); //String str = \"quick brown fox jumps\";
而第二题要做完整还是比较复杂的,他要考察每个单词的长度!然后补齐!
“%”还要对只有一个%的情况的过滤!
完整的话,还要考虑,单词字长超过8的时候,就要考虑,后续单词的排列了!
一句话,自己动手,什么都清楚!
----------------解决方案--------------------------------------------------------
----------------解决方案--------------------------------------------------------
----------------解决方案--------------------------------------------------------