133 Posted Topics
Re: [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 … | |
Re: thines01, I was thinking the same thing. [quote=koricha]what should be the output of sparse array ?[/quote] What do you mean by output? | |
Re: 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 | |
Re: So it is the same as the function above but the chain that made A & B is empty at the end? | |
Re: 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. … | |
Re: 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 … | |
Re: 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] | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: What did you want the output to look like? | |
Re: [quote]right up until I initialise a new object in main of class Matrix[/quote] Post that code and Loader code. | |
Re: 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 … | |
Re: If you didn't delete them, what do file1, file2 and file3 look like? | |
Re: 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 … | |
Re: 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. | |
Re: 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 … | |
Re: [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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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. | |
Re: 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 … | |
Re: May not be the best thing to do, but here. [code] const char *Account::getName() const { return AccName; }[/code] | |
Re: 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: $ … | |
Re: 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, … | |
Re: 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); … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … |
The End.