133 Posted Topics

Member Avatar for hwoarang69
Member Avatar for shywolf91

[LIST=1] [*]I would change the [icode]MakeArray()[/icode] function to populate the board as 10 x 28 not a 12 x 30. In the sample output link you gave the 'O' are not on the boarder of the board. I would also rename the name[][] array to board, it just makes more …

Member Avatar for shywolf91
0
2K
Member Avatar for koricha

thines01, I was thinking the same thing. [quote=koricha]what should be the output of sparse array ?[/quote] What do you mean by output?

Member Avatar for histrungalot
0
94
Member Avatar for mrmodest34

The cout in the if of i%2 would be c3(n/2) because every even number the statement will be true. And the plus 2 looks right. If I'm wrong don't worry 20+ people will be happy to point out I'm wrong. Either way you get an answer

Member Avatar for histrungalot
0
209
Member Avatar for ashsha
Member Avatar for ashsha
0
182
Member Avatar for yongj

Let me make sure that I understand what you want to do. [LIST=1]Read in a file line by line. [*]Save that line into a DynString object. [*]As you read the next line, keep what is in the current pBuff and append the new line to the end of the pBuff. …

Member Avatar for histrungalot
0
282
Member Avatar for stevo7624

The logic checks might be reducible, but test this out. [code]#include <iostream> using std::cout; using std::endl; int main(){ int a(4),b(1); if ( (a == 1 && b != 1 ) || (b != 1 && a > b)) { cout << "A wins" << endl; } else if ( (b …

Member Avatar for stevo7624
0
128
Member Avatar for msrikanth

See if this works for you [code]#!/bin/csh rm ./tmp.txt >& /dev/null foreach line ( "`cat sample.txt`" ) set line = "$line:gas/this/that/" echo $line >> ./tmp.txt end mv ./tmp.txt sample.txt [/code]

Member Avatar for histrungalot
0
7K
Member Avatar for Dec28

If I understand, you are going to use this with pipes later so would leave the output of this program as ASCII. That way it is easy to debug. As for the "passing of a single variable", you are working with pipes and you would not be passing variables but …

Member Avatar for histrungalot
0
247
Member Avatar for cameronchuck

Your not getting anything because the [icode]string infix = exp;[/icode] is not the [icode]exp[/icode] read in at line 15 of calc.cpp (scope issue). [U][B]I replaced your MyStack with std::stack[/B][/U] and made the fix above and it Segfaults in [icode]check()[/icode]. You can see that for the input of "5+5" the post …

Member Avatar for histrungalot
0
3K
Member Avatar for aravindj80

Not having your input files, you are going to have to check to see if this works for the types of patterns you have in your files. See if this helps [code]#!/usr/bin/perl use strict; use warnings; use IO::Compress::Gzip qw(gzip $GzipError); if ( !defined($ARGV[0]) || !defined($ARGV[1]) || !defined($ARGV[2])){ print "Usage: $0 …

Member Avatar for histrungalot
0
184
Member Avatar for raul8
Member Avatar for phorce

[quote]right up until I initialise a new object in main of class Matrix[/quote] Post that code and Loader code.

Member Avatar for histrungalot
0
164
Member Avatar for cdea06

This will get you started. [U][B]You still have to fix if you enter a space for word1 and word2 to will say they are anagram.[/B][/U] Because the check on count is against zero, if we never increment or decrement count it will still be zero and it thinks its an …

Member Avatar for cdea06
0
86
Member Avatar for kalyanilinux
Member Avatar for histrungalot
0
160
Member Avatar for biojet

Not really sure what is going now, but I will take a guess. I think this does what you want. The first value was lost in the read at the top of the while loop. That is why I changed the order where $rec is read. Hope this helps. [code]#!/usr/bin/perl …

Member Avatar for biojet
0
178
Member Avatar for randrum1707

Did you try [code]strcmp(AccountArray[j - i].getAccountNumber().c_str(), bucket.getAccountNumber().c_str() )[/code] This should work but you could compare strings directly.

Member Avatar for randrum1707
0
1K
Member Avatar for triumphost

Line 12 would have to return a reference to CustomType. As for line 17, I'm not sure what operator you want to overload. Currently you are returning a copy of the ArrayOfTypes (vector<CustomType>), but that is not what is in the return type of the function call. What do you …

Member Avatar for mike_2000_17
0
171
Member Avatar for hystaspes

[B][U]I think this is correct but what do you think?[/U][/B] It would have to be 2^2n <= c*2^n, because its f(x) = O(g(x)). Here f(x) = 2^2n and g(x) = 2^n. 2^2n <= c*2^n Check it out, if true log2(2^2n) <= log2(c*2^n) for some n > n0 2n <= log2(c)+n …

Member Avatar for Rashakil Fol
0
31K
Member Avatar for Sundown G

I will have to think about if I could do it without recursion, but here is a cleaned up version with recursion. [code]#include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #define Plain "plain.txt" #define MAX_LENGTH 100 void doIt(FILE *fp, char *str, char *alpha, int numLength){ int i; if ( --numLength …

Member Avatar for Sundown G
0
138
Member Avatar for onew1ng3d

You already did by the declaration of WordArray words[10000]; The is allocated off the stack and you don't have to do anything. If you did: WordArray [B]*[/B]words[10000], then you would have to allocate memory with a for loop like you have above. That is because its an array of pointers …

Member Avatar for histrungalot
0
80
Member Avatar for ItecKid

What is the expected result? I get [code]$ ./a.out 16 14 | ./a.out Height: 16 Width: 14 $[/code] When you say pipe, I think of [url]http://linux.die.net/man/2/pipe[/url]. You are using the pipe-ing of the shell and reading/writing to standard in and out. Your program is not making a call to the …

Member Avatar for histrungalot
0
189
Member Avatar for juce

Not sure what you mean. Like this? [code]#include <string> #include <iostream> #include <algorithm> using namespace std; string strUnion(string &s1,string &s2){ string::iterator it; string s3(s1); size_t pos; for(it=s2.begin();it!=s2.end();it++){ //Loop through s2 if ( (pos = s1.find(*it)) == string::npos){ s3.append(1,*it); } } sort(s3.begin(),s3.end()); return s3; } int main(){ string s1="abc"; //Set up …

Member Avatar for histrungalot
0
128
Member Avatar for faithful4ever

The way I see it is you have two things you have to keep track of: the result that you are building and in what 10's position you need to save the current modulo result in (basePos). You have the result but you need to build it [b][u]not set[/u][/b] (*result …

Member Avatar for histrungalot
0
742
Member Avatar for randrum1707

This compiles for me. [code] class Database { private: static const int num=10; int v[num]; }; int main(){ Database db; return 0; } [/code] Just remember that the static means that is only one copy of this number for all classes.

Member Avatar for randrum1707
0
157
Member Avatar for chuyauchi

exptRoll is not an array. Its a double that you passed into displayResult(). I see that expected is an array and it probably had what the calculated expected value should be for rolling dice. I think that exptRoll might not be needed. If you have the expected percentage for each …

Member Avatar for histrungalot
0
80
Member Avatar for randrum1707

May not be the best thing to do, but here. [code] const char *Account::getName() const { return AccName; }[/code]

Member Avatar for WaltP
0
101
Member Avatar for tap3ah

Do it like [code]#!/bin/bash eval "$(date "+yr=%Y mh=%m dy=%d hr=%H mt=%M sd=%S")" echo "year=$yr ; month=$mh ; day=$dy ; hour=$hr ; minute=$mt ; second=$sd" eval "$(command time -p sleep 2 2>&1 | awk 'BEGIN{ORS=" "}{print $1"="$2}')" echo "real = $real ; user= $user ; system = $sys" [/code] Output: $ …

Member Avatar for tap3ah
0
152
Member Avatar for Sundown G

See if this helps. BUFSIZ was not what you think. I replaced it with a hardcode value, changed it if you like. [code]#include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <string.h> int main(){ FILE *read_fp; FILE *read_sed; int chars_read; char command[1024] = "grep -n -w "; char buffer[1024 + 1]; memset(buffer, …

Member Avatar for Sundown G
0
583
Member Avatar for infantheartlyje

On line 17 and 21 you are passing 0 for the uorl value all the time. You need to add an if else just like the others [code]// Code starting at line 15 in binary function, // Fix it in both else ifs else if(m<a[mid]) { if (uorl==0) return binary(a,m,l,mid-1,0); …

Member Avatar for histrungalot
0
4K
Member Avatar for biojet

See if this does what you want. [code]#!/usr/bin/perl use strict; use warnings; if ( !defined($ARGV[0])){ print "\nUsage: $0 <name>\n"; print " Example: $0 AGQQ01000003.1\n\n"; exit; } my ($filename3,$filename,$printIt) = ('file_out.txt','dna.txt',0); my @columns; my $pat = quotemeta($ARGV[0]); open my $fh, '<', $filename or die "Failed to open $filename: $!"; open my …

Member Avatar for biojet
0
158
Member Avatar for skorchio

Shouldn't it be rad2deg and not deg2rad? Also with atan the return value is in the range [-pi/2, pi/2]. Maybe use atan2 which the return value is in the range [-pi, pi], but you'll need to change to return [0,360). Start with an easy test like 0, 45, 180, 270 …

Member Avatar for histrungalot
0
1K
Member Avatar for PhoenixInsilico

Your file has space and other things: [code]$ od -tx1 -c -A d paragraph.txt | more 0000000 3c 70 20 73 74 79 6c 65 3d 27 74 65 78 74 2d 61 < p s t y l e = ' t e x t - a 0000016 6c …

Member Avatar for histrungalot
0
120

The End.