begum wrote in message
<11************ *********@b28g2 000cwb.googlegr oups.com>...
i write a program about finding the max value of a subseqence in a
given sequence. i write but i finf lots of syntax mistakes and i
can't do them in correct. please help me.
Thanks;
Begum
here is the program
#include <iostream>
#include <conio.h>
[ from a note in MinGW ]
/*
* conio.h
<snip copyright>
* Low level console I/O functions. Pretty please try to use the ANSI
* standard ones if you are writing new code.
*/
>#include <iomanip.h>
You probably mean <iomanip>.
>#pragma hdrstop
Compiler specific. (?).
>template <class someTypeclass Sum{
private:
someType arr[100];
public:
void add();
void get_sequence();
};
>template <class someType>
void Sum<sumType>::a dd(){
int i;
cout<<"****PLEA SE GIVE A SUBSEQUENCE WHICH IS TO FIND THE MAX.
VALUE ****\n"<<endl;
cin>>"%d",&d>>e ndl;
???? What the....?
You can't input to "%d" !!
You can't input to endl !!
[ You can't just mix/replace scanf syntax with iostreams. ]
Try:
cin >i;
}
template <class someType>
void Sum<sumType>::g et_sequence(){
int maxSum=0;
int thisSum=0;
// int j;
Unused except in 'for()', so, why don't you put it in the 'for()'?
// for (j=0; j<101; j++){
for (int j(0); j<101; ++j){
thisSum +=a[j];
There is NO 'a' anywhere!! Did you mean the 'arr[]' in your class?
if( thisSum maxSum ){
maxSum = thisSum;
} // if(>)
else if( thisSum < 0 ){
thisSum=0;
} // else if(<)
return maxSum;
Sure you want to 'return' from inside your loop?
} // for(j)
>} // Sum<sumType>::g et_sequence() end
>void main (){
Ahhh, I see now!! You are using code from the early 1980s!!
int main (){ // main() *always* returns an int!!
// void add();
// void get_sequence();
// [ those just declare some functions inside main. (and never define
them!) ]
Sum<intsum;
sum.add();
sum.get_sequenc e();
return 0;
}
Fix all that and try again. OK?
[ I assume you'll have new questions. ]
--
Bob R
POVrookie