Search found 6 matches

by JW
Sun Feb 22, 2004 3:53 am
Forum: Volume 1 (100-199)
Topic: 101 - The Blocks Problem
Replies: 635
Views: 41529

My new code is below. [cpp]#include <iostream> #include <vector> using namespace std; class Blocks { typedef vector<unsigned short> cvectype; vector<cvectype> vec; class block_pos { public: unsigned short row; unsigned short column; block_pos(unsigned short r, unsigned short c):row(r), column(c){} }...
by JW
Sun Feb 22, 2004 3:51 am
Forum: Volume 1 (100-199)
Topic: 101 - The Blocks Problem
Replies: 635
Views: 41529

Thank aditya. I used "-Wall" keyword to compile my program, I found some warnings, and I have already fixed it. However, it still got a "compile error".

I saw your code use file to input. Don't use file, just use keyboard to input, and output the result to screen.
by JW
Sat Feb 21, 2004 6:16 am
Forum: Volume 1 (100-199)
Topic: 101 - The Blocks Problem
Replies: 635
Views: 41529

101 Compile Error.

I use gcc 3.2.2, and compiled it successfully. [cpp]#include <iostream> #include <vector> using namespace std; class Blocks { typedef vector<short> cvectype; vector<cvectype> vec; class block_pos { public: short row; short column; block_pos(short r, short c):row(r), column(c){} }; block_pos block_fi...
by JW
Sun Feb 15, 2004 5:30 am
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 187913

I think C++ is more powerful than C in this problem. [cpp]#include <iostream> using namespace std; typedef struct cycle { int i, j, maxcycle; struct cycle *next; }LIST; unsigned int findmaxcycle(unsigned int min, unsigned int max) { register unsigned int n, counter, k, maxcycle; maxcycle = 0; counte...
by JW
Sun Feb 15, 2004 4:48 am
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 187913

Thank nightdog.
Do you mean my input and output are wrong?
by JW
Sat Feb 14, 2004 4:29 pm
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 187913

My code has got LT. Why? [c]#include <stdio.h> unsigned int findmaxcycle(unsigned int i, unsigned int j) { register unsigned int n, counter, min, max, k, p; static cycles[999999]; counter = 1; k = 1; if (i > j) {min = j; max = i;} else {min = i; max = j;} for (k = min; k <= max; k++) { n = k; while ...

Go to advanced search