From: Brown Bannister on 31 Mar 2010 08:52 From the above it follows by reading the operator we obtain the first character extracting different white characters. If you call scanf function, read the current character, whether it is white character or not. Note the difference between the two ways of reading may be removed if canceled skipws bit of member x_flags class ios (default value of this bit is one). If scanf function, field from reading begins with the first character different from white characters and ends when the next character is white, or no longer corresponds to the character format. When reading a string, maximum length of the field, reading, determine the width member function of class ios. It is true what is said about the width member function, but in this case value shall be construed as x_width maximum length of the field, reading, instead of the minimum length of the field in which is displayed. An important advantage of membership function width, versus scanf function is the current function width parameter may be any expression, while the value for scanf function may be only one constant. This will be used to eliminate errors (may occur because of reading a character more than the allocated memory). Consider the following example for illustration. Stream12.cpp file: # include <iostream.h> # include <conio.h> int main () ( clrscr (); char * t; int max; court << "max ="; cin>> max; t = new char [max], / / at most max-1 characters and / / Null character court << "Read up" <<max-1 << "characters)"; cin.width (max); cin>> t; court << "characters read are:" <<t; delete [] t; return 0; ) Run the program get the following result (s reveal data entry). max = 5 Read more than 4 characters: abcdefghij The characters read are: abcd It is noted although the entry has typed more characters, not to read more than the number of characters can save the space given string. If extraction operations may be used fillers defined in paragraph, except manipulator endl, ends, flush and setbase. Manipulator may be used only WAS operations of extraction. You may use other member functions of class ios, eg member function setf. The above is written and declared to be released to the public as intellectual property belonging to the author and creator. Signed, Martin Michael Los Angeles, California On Mar 31, 1:28 am, "H. J. Sander Bruggink" <brugg...(a)uni-due.de> wrote: > On 03/31/2010 03:39 AM, Brown Bannister wrote: > > > begin > > /* The following for-loop is the guessing stage*/ > > for i=1 to N do > > X[i] := choose(i); > > endfor > > > /* Next is the verification stage */ > > Write code that does not use "choose" and > > verifies if X[1:N] is a correct solution to the > > problem. > > end > > What is precisily the goal of your post? To explain the class of > NP-problems? > > An NP-problem is defined to be a problem that can be solved in > polynomial time (that's what the P is for) by a non-deterministic Turing > Machine (that's what the N is for). It's not very surprising, therefore, > that NP-problems can be solved in polynomial time by non-deterministic > pseudocode. > > groente > -- Sander
From: Brown Bannister on 31 Mar 2010 08:53 On Mar 30, 8:31 pm, "George Jefferson" <Geo...(a)Jefferson.com> wrote: > "How did I solve an NP-Complete problem in polynomial-time?" > > Very simple, you changed the laws of logic! Quite impressive! From the above it follows by reading the operator we obtain the first character extracting different white characters. If you call scanf function, read the current character, whether it is white character or not. Note the difference between the two ways of reading may be removed if canceled skipws bit of member x_flags class ios (default value of this bit is one). If scanf function, field from reading begins with the first character different from white characters and ends when the next character is white, or no longer corresponds to the character format. When reading a string, maximum length of the field, reading, determine the width member function of class ios. It is true what is said about the width member function, but in this case value shall be construed as x_width maximum length of the field, reading, instead of the minimum length of the field in which is displayed. An important advantage of membership function width, versus scanf function is the current function width parameter may be any expression, while the value for scanf function may be only one constant. This will be used to eliminate errors (may occur because of reading a character more than the allocated memory). Consider the following example for illustration. Stream12.cpp file: # include <iostream.h> # include <conio.h> int main () ( clrscr (); char * t; int max; court << "max ="; cin>> max; t = new char [max], / / at most max-1 characters and / / Null character court << "Read up" <<max-1 << "characters)"; cin.width (max); cin>> t; court << "characters read are:" <<t; delete [] t; return 0; ) Run the program get the following result (s reveal data entry). max = 5 Read more than 4 characters: abcdefghij The characters read are: abcd It is noted although the entry has typed more characters, not to read more than the number of characters can save the space given string. If extraction operations may be used fillers defined in paragraph, except manipulator endl, ends, flush and setbase. Manipulator may be used only WAS operations of extraction. You may use other member functions of class ios, eg member function setf. The above is written and declared to be released to the public as intellectual property belonging to the author and creator. Signed, Martin Michael Los Angeles, California
From: Brown Bannister on 31 Mar 2010 08:59 Insert operator Write operations standard output device in file, or in area memory may be made with operator <<, in this case called insert operator. Operate from left side operator <<be object class ostream (naturally derive class and class object are considered object class ostream ostream). For write operation standard output device use may be subject to court approval. Operand i of right operator <<be expression. Expression appropriate type be overload operator <<. For standard type insert operator overload with member function from: ostream & operator <<(nume_tip_standard); Note abstract type programmers may overburden insertion operator. Consider example present, more details from illustrate similar use printf function. Stream1.cpp file: # include <stdio.h> # include <iostream.h> # include <conio.h> int main () ( clrscr (); int x = 230; court <<x << '\ n'; printf ( "% d \ n", x); double y = 543.67; court <<y << '\ n'; printf ( "% lg \ n", y); char z = 'a'; court <<z << '\ n'; printf ( "% c \ n", z); char t [] = "example"; court <<t << '\ n'; printf ( "% s \ n", t); int * v = &x; court <<v << '\ n'; printf ( "% p", v); return 0; ) Run program obtain: 230 230 543.67 543.67 of of example example 0xfff4 FFF4 Note string display result data type int, double char is same. Display pointer, value display is same, but different format (use printf write with capital letters display on, and when write court use small letter display base). Because operator <<return reference current class, operator may apply to chain. Shown by following example. Stream2.cpp file: # include <stdio.h> # include <iostream.h> # include <conio.h> int main () ( clrscr (); int x = 10; court << "x (after increment) =" <<x << "\ Nx (before increment) =" <<x + +; x = 10; court << "\ n"; printf ( "x (after increment) =% d \ \ NX (before increment) =% d ", x, x + +); return 0; ) Obtain: x (after increment) = 11 x (before increment) = 10 x (after increment) = 11 x (before increment) = 10 Beside fact insert operator may apply to chain, evaluate expression show reverse order compare display. Explain face value fast increment, baseline show printf function valid for same. Order expression evaluation, display use chain insert operator, explicit illustration by example. Stream3.cpp file: # include <iostream.h> # include <conio.h> char * f1 () ( court << "evaluation function f1 \ n"; return "Displaying 1 \ n"; ) char * f2 () ( court << "Evaluation function f2 \ n"; return 'Display 2 \ n "; ) int main () ( clrscr (); court <<f1 () <<f2 (); return 0; ) Run program get: Evaluation function F2 Evaluation function f1 Display 1 Display 2 Evaluate function F2 do before evaluate function f1. Member function setf C language printf function display data according to format specified by programmer. This is done with hierarchy class define C++. Class ios once member x_flags say, refer to format will make operations input / output. Also class ios define an enumeration type may refer to member x_flags bit. Type list follows: class ios ( public: ... enum ( skipws = 0x0001, / / skip over white characters to make read left = 0x0002, / / write left cadreazÄ right = 0x0004, / / write right cadreazÄ internal = 0x0008, / / character will fill after / / Sign, after basic December = 0x0010, / / convert to decimal October = 0x0020, / / convert to octal hex = 0x0040, / / convert to hexadecimal showbase = 0x0080, / / display showpoint = 0x0100, / / decimal point / / Real numbers uppercase = 0x0200, / / hex display large letters showpos = 0x0400, / / positive integers display / / sign in front scientific = 0x0800, / / display real numbers with exponent fixed = 0x1000, / / display real number without exponent unitbuf = 0x2000, / / buffer zone writes videazÄ stdio = 0x4000 / / write stdout and stderr videazÄ ); ... ); Date x_flags has default member for each standard type. Thus result display data types are standard, by default display same result printf function, user specified format corresponds to types. Present relationship between type and format a specific table. If change Bytes date x_flag State, display result changes format specified. Achieve by means of member functions. Type specified by appropriate format int% d long% ld unsigned% u unsigned long% lu Float% g double% lg % Lg long double char% c String% s Table. The relation between types specify format In order to work more easily with appropriate format bits, three groups determine bits member x_flags. Each group has name, actual name of type long static constant declared by class ios. Groups are: - Adjustfield (right, left and internal), Crop mode; - Basefield (December, October and hex), determine base; - Floatfield (scientific and fixed), write real numbers. Each group has property only one bit may be set in the group. Bits date may be set by State x_flags member function setf class ios. State setf function has two forms: long setf (long form); and long setf (long setbit, long group); The first version of member function setf Set appropriate bits long type parameter: format. If bit form is equal to one, then corresponding bit will be x_flags and if format bit is zero, bit corepunzÄtor of x_flag remains unchanged. The second version of member function setf Set a bit in one of three groups adjustfield, basefield or floatfield. With parameter set bit - determines bit to be set. The location should be a bit, and zero otherwise. The second parameter may be a specific group name. In this case canceled Bytes group then to set bits in setbit. Both versions of setf function return its State x_flag before the change. Refer to bits with member x_flags is ios class name, followed by transmission bit resolution and name of enumeration type. Refer to name of group is similar, înlocuid name of list type group name. Use setf State illustrate by example. Stream.cpp file: # include <stdio.h> # include <iostream.h> # include <conio.h> void binar_c (long x) ( printf ( "x_flags:"); for (int i = 8 * sizeof (long) -1, i> = 0, i-) ( printf ( "% d", (x>> i) & 1); if (! (i% 8)) printf ( ""); ) printf ( "\ n"); ) nume_bit_1 void (char * s [], long x) ( for (int i = 0; i <15; i++) if ((x>> i) & 1) printf ( "%-16s", s [i]); printf ( "\ n"); ) void display (char * s [], long x) ( binar_c (x); nume_bit_1 (s, x); ) int main () ( char * nume_enum [] = ( "skipws" "left", "right", "internal" "December", "October", "Hex" "showbase" "showpoint" "uppercase" "showpos" "scientific" "fixed", "unitbuf" "stdio" ); clrscr (); display (nume_enum, cout.flags ()); cout.setf (ios:: oct, ios:: basefield); display (nume_enum, cout.flags ()); court <<36 << '\ n'; display (nume_enum, cout.flags ()); cout.setf (ios:: showbase); cout.setf (ios:: hex, ios:: basefield); display (nume_enum, cout.flags ()); court <<36 << '\ n'; display (nume_enum, cout.flags ()); return 0; ) Run program get: x_flags: 00000000 00000000 00100000 00000001 skipws unitbuf x_flags: 00000000 00000000 00100000 00100001 skipws October unitbuf 44 x_flags: 00000000 00000000 00100000 00100001 skipws October unitbuf x_flags: 00000000 00000000 00100000 11000001 skipws hex showbase unitbuf 0x24 x_flags: 00000000 00000000 00100000 11000001 skipws hex showbase unitbuf Function display, in example, show first State x_flag bits, write name bit value equal to one. First set bit in October show constant integer value 36, use octal conversion. Thus obtain value 44. Set and showbase hex bits, show constant value, obtain value 0x24. Note use second version member function setf to set hex bit, obtain annul bit in October. Note name type enumeration value of all bits show by example follow function: nume_bit void (char * s [], long x) ( for (int i = 0; i <15; i + +) printf ( "%-11s:% 2d \ n", s [i], (x>> i) & 1); ) Observe to show member x_flags bits use printf function hierarchy class declare iostream.h file. Function of form void binar_stream (long x) ( for (int i = 8 * sizeof (long) -1, i> = 0, i -) court <<((x>> i) & 1) <<(i% 8? "" ""); court << '\ n'; ) State show correct bits x_flag, errors occur if bit is set showbase one in October or hex bits. In these appear set, so integers precede zero if conversion to octal, and 0x or 0X for hex conversion. Membership functions width, fill and precision Printf function determine minimum length of field to display date. Value stored on class ios x_width State. Default State x_width date is zero, means shown will be many characters needed. State data value may determine or modify x_width width member function of class ios. It has two forms: int width (); and int width (int length); First form of member function returns width x_width State. Second approach to x_width State amends value determined by length value, and returns old value of x_width. It is important to note operation Guestbook / output value will reset member x_width to zero. So if it determines length of field before a paste operation, then use default. If length field display is greater than number of characters to display Crop is made by default to the right, and remaining space fills with filler characters. By default fill characters are spaces, but may be changed with member function ios to fill the class. Class ios has every member x_fill to save character filling. Fill member function has two forms: char fill (); and char fill (char car); The first version returns the current fill character. The second form of the function member fill amends date x_fill State car character, and returns the old value of the fill character. If the display value of real numbers determines accuracy, ie number of decimal places, used to write data. Class ios has every member x_precision, which defaults to zero. By default real type data shows six decimal places. Member function has two forms Precision: int precision (); and int precision (int p); The first variant of the precision member function returns the current value of member x_precision. The second variable assigns value of parameter p and returns its previous x_precision State. Member functions use precision sup_fun1.cpp file to determine number of digits to display when calculating the number Ï. Present below another example, State use functions of this paragraph. Stream5.cpp file: # include <iostream.h> # include <stdio.h> # include <conio.h> const double pi = 3.141592653; scrie_width_precision_c void () ( printf ( "x_width:% d \ n", cout.width ()); printf ( "x_precision:% d \ n", cout.precision ()); ) afisare_pi_c void () ( printf ("*"); court <<pi; printf ( "* \ n"); ) int main () ( clrscr (); scrie_width_precision_c (); afisare_pi_c (); cout.width (7); cout.precision (2); scrie_width_precision_c (); afisare_pi_c (); scrie_width_precision_c (); afisare_pi_c (); cout.width (7); cout.fill ('@'); scrie_width_precision_c (); afisare_pi_c (); return 0; ) Run program get: x_width: 0 x_precision: 0 * 3.141593 * x_width: 7 x_precision: 2 * 3.14 * x_width: 0 x_precision: 2 * 3.14 * x_width: 7 x_precision: 2 * @ @ @ 3.14 * The character '*' has been shown to highlight the field is writing data. Note indeed the default data and x_width State x_precision is zero, so the display is six decimal places. After changing the data member values x_width = 7 respectively x_precision = 2, the display is made in the field of seven characters, with two decimal places, the number of frames at right. After writing operation value becomes zero x_width State, but value does not change x_precision State. Use width member function assign new value member x_width of seven. Next use to determine function member fill a fill character other than blank character. Note instead call printf function, use the hierarchy of classes declared in iostream.h file, to achieve what it set out. For example, instead scrie_width_precision_c function should use afisare_pi_c s functions: scrie_width_precision_stream void () ( court << "x_width:" <<cout.width () << '\ n'; court << "x_precision:" <<cout.precision () << '\ n'; ) afisare_pi_stream void () ( court << "*" <<pi << "* \ n"; ) Obtain: x_width: 0 x_precision: 0 * 3.141593 * x_width: 7 x_precision: 2 * 3.14 * x_width: 0 x_precision: 2 * 3.14 * x_width: 7 x_precision: 2 * 3.14 * In this case, each time, the value of Ï is display on a field of length equal to the number of characters displayed. The reason is member x_width inserts first operation and assigns a zero first operation displaying the string "x_width", and write the value of Ï. There is a strong link between member functions listed in this paragraph and formatting of printf function. Illustrate by example. Stream6.cpp file: # include <iostream.h> # include <stdio.h> # include <conio.h> int main () ( clrscr (); const double x = 987.65432; court << "*"; cout.width (11); cout.precision (4); cout.fill ('0 '); court <<x << "* \ n"; printf ( "*% 011.4lf * \ n", x); return 0; ) Obtain: * 000987.6543 * * 000987.6543 * In example show actual type of constant value x in two ways: use streams, and use printf function. To achieve same result. Write printf function is more compact display streams are more general, because the character of filling may be any character, not just '0 '. Manipulator State x_flag bits, correspond to conversion set in another way, use special member functions call manipulators. Avantage returns a handler reference to stream, call member functions may be chained. Part of manipulator is declared in iostream.h file and in iomanip.h file. Fillers declared in iostream.h file are: endl crossing line ninth and vacuum corresponding stream buffer zone end insert character '\ 0' vacuum flush buffer zone object class ostream December decimal conversion hex hex conversion October octal conversion Set bit skipws Table. Fillers declared in iostream.h file Fillers iomanip.h declared in file: setbase (int b) set appropriate numeral base conversion system, the value = (0,8,10,16) reset iosflags (long x) delete bits specify parameter x, of State x_flags set iosflags (long x) set bits of x_flags member, specify parameter x set fill (int f) date member x_fill assign parameter value f set precision (int p) date member x_precision assign parameter value p set w (int w) date member x_width assign parameter value w Table. Fillers declared in file iomanip.h Use example of file handlers stream6.cpp transcribe as follows. Stream7.cpp file: # include <iostream.h> # include <iomanip.h> # include <stdio.h> # include <conio.h> int main () ( clrscr (); const double x = 987.65432; court << "*" <<setw (11) <<setprecision (4) <<Setfill ('0 ') <<x << "*" <<endl; printf ( "*% 011.4lf * \ n", x); return 0; ) Result obtained is identical to previous program. Fillers have appealed to the chained, so the program is simple. The following example shows value in the State x_flags binary, hexadecimal, octal and decimal. Stream8.cpp file: # include <iostream.h> # include <conio.h> # include <stdio.h> void binar_c (long x) ( printf ( "x_flags:"); for (int i = 8 * sizeof (long) -1, i> = 0, i -) ( printf ( "% d", (x>> i) & 1); if (! (i% 8)) printf ( ""); ) printf ( "\ n"); ) int main () ( clrscr (); binar_c (cout.flags ()); court << "Hexadecimal:" <<hex <<cout.flags () <<endl << "Octal:" <<October <<cout.flags () <<endl << "Decimal:" <<December <<cout.flags () <<endl; return 0; ) Result obtained is as follows: x_flags: 00000000 00000000 00100000 00000001 Hexadecimal: 2001 Octal: 20,001 Decimal: 8193 In this case it is not necessary to include file iomanip.h as manipulators hex, October and December are declared in iostream.h file. If conversion changes the way of a manipulator, it still remains valid until a further adjustment of the conversion. Overloading insert operator The above paragraphs have dealt with how to use the insertion operator for displaying data of standard types. It is desirable for the operator <<to be used for abstract data types. For example with the class of rational numbers class fraction ( int counter; int denominator; public: Fraction (int a, int b) (number = a; denominator = b;) ... ); show a fraction carried out as court <<f; where f is an object of class fraction. This may be done, overload the insertion operator for displaying objects of type fraction. Since operate from the left of the operator <<is a stream, operator overloading makes a friend function of class fraction. For a class named Class oareacare operator insert may surcharge with the following function friend: class Class ( ... friend ostream & operator <<(ostream &, class); ... ); Fraction of class overloading the insertion operator a friend function may be made as follows. Fractie2.cpp file: # include <iostream.h> # include <conio.h> class fraction ( int counter; int denominator; public: Fraction (int a, int b) (number = a; denominator = b;) friend ostream & operator <<(ostream & s, fraction f); ); ostream & operator <<(ostream & s, fraction f) ( s <<f.numerator << "/" <<f.numitor; return s; ) int main () ( clrscr (); Fraction F1 (3.5); court <<f1 <<endl; return 0; ) Program obtains: 3 / 5 So it appears reasonable number, as requested. Call insert operator may apply to the chained, because friends of the class fraction function return a reference to the current stream. Although the above method is simple and gives the correct result, it has the advantage use a friend function increases level of data protection. Protect member data may not be modified within the function friend overload insert operator. In continuation of a way to overload the operator <<, without introducing a friend function. For a certain class with class name, this is achieved by a member function display, which call the function to overload the insert operator. So: class Class ( ... public: ostream & display (ostream & s); ... ); ostream & Class:: display (ostream & s) ( ... return s; ) ostream & operator <<(ostream & s, Class C1) ( c1.afisare return (s); ) Fraction class overloading the insert operator without using a friend function may be performed as follows. Fractie3.cpp file: # include <iostream.h> # include <conio.h> class fraction ( int counter; int denominator; public: Fraction (int a, int b) (number = a; denominator = b;) ostream & display (ostream & s); ); ostream & fraction:: display (ostream & s) ( s <<counter << "/" <<denominator; return s; ) ostream & operator <<(ostream & s, fraction f) ( f.afisare return (s); ) int main () ( clrscr (); Fraction F1 (3.5); court <<f1 <<endl; return 0; ) The result obtained by executing the program is identical to that of fractie2.cpp file, but not using it friend. Entries are formatted Extraction operator Entry operations are achieved through operator>>, Which call the extraction operator. Operand i of the left extraction operator may be an object of class Istria, or a class derived from class Istra. Operand i of the right will be an expression, which may belong to both a standard type and an abstract type. If the standard types in a call to a member function of class istria form: istria & operator>> (tip_standard &); For abstract types the programmer may overburden extraction operator. To contact this scanf function, return to this example, following more detailed form. Stream9.cpp file: # include <iostream.h> # include <conio.h> int main () ( clrscr (); int x; court << "x (int) ="; cin>> x; / / scanf ( "% d", & x); double y; court << "y (double) ="; cin>> y; / / scanf ( "% lf", & y); char z [20]; court << "z (string) ="; cin>> z; / / scanf ( "% s", z); court << "read data are: \ n" << "X =" <<x <<endl << "Y =" <<y <<endl << "Z =" <<z <<endl; return 0; ) Run program get the following result (it shows the characters read from input). x (int) = 123 y (double) = 45.67 z (string) = eg The data read are: x = 123 y = 45.67 z = example The same result is obtained and follows program implementation. Stream10.cpp file: # include <stdio.h> # include <conio.h> int main () ( clrscr (); int x; printf ( "x (int) ="); scanf ( "% d", & x); double y; printf ( "y (double) ="); scanf ( "% lf", & y); char z [20]; printf ( "z (string) ="); scanf ( "% s", z); printf ( "read data are: \ \ nx =% d \ ny =% lg \ nz =% s \ n ", x, y, z); return 0; ) It follows the above cases, there is no difference between reading data from standard input using the extraction operator, namely the function scanf. However some cases may appear different. For example sequence: char c; .... cin>> c; is not identical with char c; .... scanf ( "% c", & c); The difference appears when the input current character is a white character, so space, tab or newline character (transition to new line). Present below an example which shows indeed two sequences are identical programs. We define a class for management c_alb characters, and overburden the insert operator for this class. Overloading will be made so white characters are displayed prominently ( '' for space, '\ t' for tabs and '\ n' for newline characters). Characters other than white will appear unchanged. Stream11.cpp file: # include <iostream.h> # include <stdio.h> # include <conio.h> c_alb class ( char c; public: c_alb (c_1 int) (c = c_1;) ostream & display (ostream & s); ); ostream & c_alb:: display (ostream & s) ( switch (c) ( case '\ n': s << "\ '\ \ n \'"; break; case '\ t': s << "\ '\ \ t \'"; break; case '': s << "\ '\'"; break; default: s <<c; ) return s; ) ostream & operator <<(ostream & s, c_alb car) ( car.afisare return (s); ) int main () ( clrscr (); char v; court << "Reading data (operator>>). Input ="; cin>> v; court << "character read (operator>>) is:" <<C_alb (v) <<endl; printf ( "Reading data (the function scanf). Input ="); scanf ( "% c", & v); court << "character reading (with scanf function) is:" <<C_alb (v) <<endl; return 0; ) Run program, get result of the form: Read data (operator>>). Entry = q Character read (operator>>) is: q Read data (the function scanf). Entry = q Character reading (with scanf function) is: '\ t' The first entry types a tab character, then the character 'q', followed by transition to a new line. The same is repeated and read with scanf. In writing, the character you first converted into an anonymous object type c_alb to obtain an appropriate display of white characters. From the above it follows by reading the operator we obtain the first character extracting different white characters. If you call scanf function, read the current character, whether it is white character or not. Note the difference between the two ways of reading may be removed if canceled skipws bit of member x_flags class ios (default value of this bit is one). If scanf function, field from reading begins with the first character different from white characters and ends when the next character is white, or no longer corresponds to the character format. When reading a string, maximum length of the field, reading, determine the width member function of class ios. It is true what is said about the width member function, but in this case value shall be construed as x_width maximum length of the field, reading, instead of the minimum length of the field in which is displayed. An important advantage of membership function width, versus scanf function is the current function width parameter may be any expression, while the value for scanf function may be only one constant. This will be used to eliminate errors (may occur because of reading a character more than the allocated memory). Consider the following example for illustration. Stream12.cpp file: # include <iostream.h> # include <conio.h> int main () ( clrscr (); char * t; int max; court << "max ="; cin>> max; t = new char [max], / / at most max-1 characters and / / Null character court << "Read up" <<max-1 << "characters)"; cin.width (max); cin>> t; court << "characters read are:" <<t; delete [] t; return 0; ) Run the program get the following result (s reveal data entry). max = 5 Read more than 4 characters: abcdefghij The characters read are: abcd It is noted although the entry has typed more characters, not to read more than the number of characters can save the space given string. If extraction operations may be used fillers defined in paragraph, except manipulator endl, ends, flush and setbase. Manipulator may be used only WAS operations of extraction. You may use other member functions of class ios, eg member function setf. The above is written and declared to be released to the public as intellectual property belonging to the author and creator. Signed, Martin Michael Los Angeles, California On Mar 31, 1:28 am, "H. J. Sander Bruggink" <brugg...(a)uni-due.de> wrote: > On 03/31/2010 03:39 AM, Brown Bannister wrote: > > > begin > >   /* The following for-loop is the guessing stage*/ > >   for i=1 to N do > >     X[i] := choose(i); > >   endfor > > >   /* Next is the verification stage */ > >   Write code that does not use "choose" and > >   verifies if X[1:N] is a correct solution to the > >   problem. > > end > > What is precisily the goal of your post? To explain the class of > NP-problems? > > An NP-problem is defined to be a problem that can be solved in > polynomial time (that's what the P is for) by a non-deterministic Turing > Machine (that's what the N is for). It's not very surprising, therefore, > that NP-problems can be solved in polynomial time by non-deterministic > pseudocode. > > groente > -- Sander Solve an NP-Complete Problem and Resolve P Versus NP and donate a million dollars to cure childhood cancers with http://www.alexslemonade.org Peace- <Martin>
First
|
Prev
|
Pages: 1 2 Prev: A=1, B=2, C=3... Z=26 Next: Scientists Warn Large Earth Collider May Destroy Earth |