需要算法 [英] need algorithm
问题描述
我有一个名为program的数组;
char program [500];
包括ex。此=> mp3#name#surname#age #sex#school#
阵列中有一些名字;可能有6个以上的名字,但
总计不超过500个字符。
i想要循环播放
cout<< ; name [];
i ll使用名为name的数组,大小为20;输出结果为
mp3
name
姓氏
i have an array called program;
char program[500];
it includes for ex. this=> mp3#name#surname#age#sex#school#
there are some names in the array; there may be names more than 6,but
not totaly longer than 500 chars.
i want to make this in a loop
cout<<name[];
i ll use an array called name with size 20;and the output will be
mp3
name
surname
推荐答案
jw写道:
我有一个名为program的数组;
char program [500];
它包括ex。此=> mp3#name#surname#age #sex #chchool#
数组中有一些名字;可能有6个以上的名字,但
总不超过500个字符。
我想在循环中制作这个。
cout<< name [];
我会使用一个名为name的数组,大小为20;输出将是
mp3
姓名
姓氏
i have an array called program;
char program[500];
it includes for ex. this=> mp3#name#surname#age#sex#school#
there are some names in the array; there may be names more than 6,but
not totaly longer than 500 chars.
i want to make this in a loop
cout<<name[];
i ll use an array called name with size 20;and the output will be
mp3
name
surname
这是'算法
找到第一个#在程序中的位置
将所有字符从程序开头复制到第一个#
输出所有复制的字符
找到第二个#在程序中的位置
复制所有字符从第一个#到第二个#
输出所有复制的字符
找到第三个#在程序中的位置
复制所有字符从第二个#到第三个#
输出所有复制的字符
我不太明白你所说的循环,但无论它是什么
将上述内容放入你需要的循环。
joh n
Here''s the algorithm
find the position of the first # in program
copy all the character from the beginning of program upto the first #
output all the copied characters
find the position of the second # in program
copy all the character from after the first # upto the second #
output all the copied characters
find the position of the third # in program
copy all the character from after the second # upto the third #
output all the copied characters
I don''t quite get what you are saying about loops, but whatever it is
put the above into the loop you need.
john
但我不能写代码可以帮助代码
but i cant write its code can u help with the code
jw写道:
但我不能写它的代码可以帮助代码
but i cant write its code can u help with the code
读取std :: string。
Ian
Read up on std::string.
Ian
这篇关于需要算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!