how can i write program in java to find the transpose of the graph G, where the input and the output of the program are represented as adjacency list structure.
for example:
input:
12341
outout:
1432
Why does cout has to be flushed before cin starts reading? Aren't they of different buffer? I can have reading of input into a buffer while same time putting it on output buffer (before flushing) .. 2 different buffers. I am confused here.
Quoted from here:
BW = edge(I,'zerocross',thresh,h)
specifies the zero-cross method, using
the filter h. thresh is the
sensitivity threshold; if the argument
is empty ([]), edge chooses the
sensitivity threshold automatically.
If you specify a threshold of 0, the output image has closed contours,
because it includes all the zero
crossings in the input image.
I don't understand it,can someone elaborate?
Below is my data:
Data Here 94/452O
Data more 94/4522i
Data bla 94/111
Data bla 94/459es
Data bla 94/444
items is automatically generated by some previous code but it could come out like:
items = ["Data Here 94/452O", "Data more 94/4522i", "Data bla 94/111", "Data bla 94/459es", "Data bla 94/444"]
Now currently I'm appending the following:
"\n".join(items).replace("4ke", "9") with a few other .replaces however I want it to replace/change the characters on the end of the numbers with a capital letter instead of lowercase...
Output:
Data Here 94/452O
Data more 94/4522I
Data bla 94/111
Data bla 94/459ES
Data bla 94/444
Hi ,
in my database i have phone numbers with country code , which look somthing like
0044-123456
0044-123456
0014-123456
0014-123456
0024-123456
0024-123456
0034-123456
0044-123456
0044-123456
0024-123456
0034-123456
084-123456
084-123456
i want to total up the numbers by country, something like this output
0044 (2)
0024 (2)
0034 (1)
084 (2)
064 (5)
Is it possible to do this with a SQL query?
how can i evaluate weather my test array is equal to my static constant DEFAULT_ARRAY? shouldn't my output be returning true?
public class myClass extends Sprite
{
private static const DEFAULT_ARRAY:Array = new Array(1, 2, 3);
public function myClass()
{
var test:Array = new Array(1, 2, 3);
trace (test == DEFAULT_ARRAY);
}
//traces false
i have a List and i m grouping it into different lists.
like:-List("a","b","c","it","as","am","cat","can","bat")
3 list List1:-a,b,c List2:-it,as,am List3:-cat,can,bat
how can i concat the all possible combination from this lists.
output like:
a,it,cat
b,it,cat
c,it,cat
a,am,cat
b,am,cat
c,am,cat
.
.
.
.
etc so on...
(Context: running autohotkey scripts to try and automate some tests. The plan is to take screenshots and then compare them to 'standard' screenshots to detect if output has changed).
Is there a 'clever' way to check if two png images are different?
By clever I mean other than comparing them byte by byte? (after having compared their size, obviously)
This is a sequel to a related post which asked the eternal question:
Can I have polymorphic containers with value semantics in C++?
The question was asked slightly incorrectly. It should have been more like:
Can I have STL containers of a base type stored by-value in which the elements exhibit polymorphic behavior?
If you are asking the question in terms of C++, the answer is "no." At some point, you will slice objects stored by-value.
Now I ask the question again, but strictly in terms of C++11. With the changes to the language and the standard libraries, is it now possible to store polymorphic objects by value in an STL container?
I'm well aware of the possibility of storing a smart pointer to the base class in the container -- this is not what I'm looking for, as I'm trying to construct objects on the stack without using new.
Consider if you will (from the linked post) as basic C++ example:
#include <iostream>
using namespace std;
class Parent
{
public:
Parent() : parent_mem(1) {}
virtual void write() { cout << "Parent: " << parent_mem << endl; }
int parent_mem;
};
class Child : public Parent
{
public:
Child() : child_mem(2) { parent_mem = 2; }
void write() { cout << "Child: " << parent_mem << ", " << child_mem << endl; }
int child_mem;
};
int main(int, char**)
{
// I can have a polymorphic container with pointer semantics
vector<Parent*> pointerVec;
pointerVec.push_back(new Parent());
pointerVec.push_back(new Child());
pointerVec[0]->write();
pointerVec[1]->write();
// Output:
//
// Parent: 1
// Child: 2, 2
// But I can't do it with value semantics
vector<Parent> valueVec;
valueVec.push_back(Parent());
valueVec.push_back(Child()); // gets turned into a Parent object :(
valueVec[0].write();
valueVec[1].write();
// Output:
//
// Parent: 1
// Parent: 2
}
Hi,
I have assign the value of a member variable as under:
myValue = (char*)malloc(strlen(inValue) * sizeof(char));
strcpy(mValue, inValue);
while assigning it the value was proper as(taking printf output):
http://www.w3.org/2001/XMLSchema
But, when i get its value after wards i get it as:
http://www.w3.org/2001/XMLSchema(!
What could be the problem for this issue
Hi I have a table test as below
NAME
---------
abc1234
XYZ12789
a12X8b78Y9c5Z
I try to find out the count of number of numbers and characters in the string as
select name,length(replace(translate(lower(name),'abcdefghijklmnopqrstuvwxyz',' '),' ','')) as char_count,
length(replace(translate(name,'1234567890',' '),' ','')) as num_count
from test6;
Its executing fine giving the output
NAME CHAR_COUNT NUM_COUNT
abc1234 4 3
XYZ12789 5 3
a12X8b78Y9c5Z 7 6
But my question is there any option by not giving the abcdefghijklmnopqrstuvwxyz
and 1234567890 manually
There are often times I'll grep -l whatev file to find what I'm looking for. Say the output is
1234: whatev 1
5555: whatev 2
6643: whatev 3
If I want to then just extract the lines between 1234 and 5555, is there a tool to do that? For static files I have a script that does wc -l of the file and then does the math to split it out with tail & head but that doesn't work out so well with log files that are constantly being written to.
I have a log file that is constantly growing, how can I watch and parse it via a ruby script. The script will parse each new line as it is written to the file and output something to the screen when the new line contains the string 'ERROR'
I would like to have a subroutine as a member of a hash which is able to have access to other hash members.
For example
sub setup {
%a = (
txt => "hello world",
print_hello => sub {
print ${txt};
})
return %a
}
my %obj = setup();
$obj{print_hello};
Ideally this would output "hello world"
Hello,
I have written a webservice which is taking URL as an input and producing a JSON respone. My problem is that now I have list of 1000 URLs and want to execute maximum threads of Webapplications to get output. Like I want to execute 100 instances of webservice at a time to get response.Please can anybody give some guidance how can I do it using java.
Thank you in advance
I'd like to use the data from my wordpress site in an API form. Maybe REST with JSON output. I'm wondering if there's any plugins that automatically make the wordpress data accessible from outside the site its running on, similar to the way most web APIs work.
When generating specs with :
rails g controller Home index
A spec is generated with the older object.should syntax
require 'spec_helper'
describe HomeController do
describe "GET 'index'" do
it "returns http success" do
get 'index'
response.should be_success
end
end
end
Is it possible to configure the generator to use the expect syntax instead?
Desired output:
require 'spec_helper'
describe HomeController do
describe "GET 'index'" do
it "returns http success" do
get 'index'
expect(response).to be_success
end
end
end
in config/application.rb:
config.generators do |g|
g.test_framework :rspec, fixture: true
g.fixture_replacement :factory_girl, dir: 'spec/factories'
g.view_specs false
g.stylesheets = false
g.javascripts = false
end
I asked a question like this in an interview for a entry level programmer:
var instance1 = new myObject{Value = "hello"}
var instance2 = instance1;
instance1.Value = "bye";
Console.WriteLine(instance1.Value);
Console.WriteLine(instance2.Value);
The applicant responded with "hello", "bye" as the output.
Some of my co-workers said that pointers are not that important anymore or that this question is not a real judge of ability.
Are they right?
I tried this,
#!/bin/ksh
for i in {1..10}
do
echo "Welcome $i times"
done
in Ksh of an AIX box.
I am getting the output as,
Welcome {1..10} times
What's wrong here?
Thanks.
In a perl script, I'm trying to accept input without blocking and without echoing the characters entered (The script is producing output and I want to have 'hotkeys' to alter its behaviour).
I got as far as using
use Term::ReadKey;
ReadMode( "cbreak", STDIN );
if($input = ReadKey($pause_time, STDIN)){
#process input
}
But once the user types anything then the script stops until a newline is entered. I'd like the input to be processed per-character, without waiting for a newline.
Input integer array:
a[8] = { a1, a2, a3, a4, b1, b2, b3, b4 }
Output array:
a[8] = { a1, b1, a2, b2, a3, b3, a4, b4 }
Forget all corner cases, make sure your solution works for any int array of size 2n. You can use one or two temp variables for looping or anything, but you shouldn't use any temp arrays/stacks/queues etc to store entire array or part of array.
I'm able to get answer in O(n*log n), but I'm looking for better solution.
I have a bunch of types (eg. LargePlane, SmallPlane) that could be in this collection i've made, how do i print like LargePlane? I've tried like typeOf() and stuff but it doesn't work. Within like a toString()? So when i output the collection it states what type it is.
I'm trying to pass in both the field and the value in a find call:
@employee = Employee.find(:all,
:conditions => [ '? = ?', params[:key], params[:value].to_i)
The output is
SELECT * FROM `employees` WHERE ('is_manager' = 1)
Which returns no results, however when I try this directly in mysqsl using the same call without the '' around is_manager, it works fine. How do I convert my params[:key] value to a symbol so that the resulting SQL call looks like:
SELECT * FROM `employees` WHERE (is_manager = 1)
Thanks,
D