Given a grid of any height and width, write an algorithm to traverse it in a spiral. (Starting at the top left and ending in the middle) without passing over previously visited nodes. Without using nested loops.
I was looking at someone's code and saw that he repeatedly declared
PrintStream out = System.out;
and later called
out.println("blah");
I actually thought this was kind of neat. Is this a common practice? Was he just being fancy?
I have one Map that contains some names and numbers
Map<String,Integer> abc = new TreeMap<String,Integer>();
It works fine. I can put some values in it but when I call it in different class it gives me wrong order. For example:
I putted
abc.put("a",1);
abc.put("b",5);
abc.put("c",3);
some time it returns the order (b,a,c) and some time (a,c,b).
What is wrong with it? Is there any step that I am missing when I call this map?
i am starting with this table:
SELECT [Lab Occurrence Form].[Practice Code], [Lab Occurrence Form].[1 0 Preanalytical (Before Testing)], Count([Lab Occurrence Form].[1 0 Preanalytical (Before Testing)]) AS [CountOf1 0 Preanalytical (Before Testing)]
FROM [Lab Occurrence Form]
WHERE ((([Lab Occurrence Form].[Occurrence Date]) Between [Forms]![By Number]![Text4] And [Forms]![By Number]![Text2]))
GROUP BY [Lab Occurrence Form].[Practice Code], [Lab Occurrence Form].[1 0 Preanalytical (Before Testing)]
HAVING ((([Lab Occurrence Form].[Practice Code])<>"") AND ((Count([Lab Occurrence Form].[1 0 Preanalytical (Before Testing)]))<>0));
it selects 3 columns but i need to aggregate the comments and put it in the fourth column where the first two values are the same
So, I've been doing android application tutorials and everytime I create a package, for example the helloAndroid tutorial is com.example.android. When it saves this to src it creates a folder for com, another for example and one last one for android. So it gives me the error "class com.example.android does not exist" because its broken into different folders.
If anyone can help me out please email me at: [email protected]
Thank you very much.
There are two arrays with equivalent size. How to decide whether these two arrays contain the same set of elements, but the orders of these elements in the respective arrays are different.
For instance.
A = [a, b, c]
B= [b, c, a]
I am attempting to put all my database connections in 1 php file, rather than in each of my individual php pages. I have the following:
//conn.php:
<?php
class conn {
var $username = "name";
var $password = "password";
var $server = "localhost";
var $port = "3306";
var $databasename = "db";
var $tablename = "tablename";
var $connection;
public function getConnected() {
$this->connection = mysqli_connect(
$this->server,
$this->username,
$this->password,
$this->databasename,
$this->port
);
}
}
?>
// file.php:
<?php
require_once("conn.php");
class myClass{
public function con() {
$conn = new conn();
$conn->getConnected();
}
public function myF() {
$stmt = mysqli_prepare($conn->connection, "SELECT * FROM $conn->tablename");
mysqli_stmt_execute($stmt);
}
}
?>
I then call this as follows:
$myNew = new myClass();
$myNew-con();
$myNew-myF();
When I call this, I get the following error:
Undefined property: myClass::$connection
What am I doing wrong?
Rvalues IMHO are great improvement in C++, but at the beginning the're seems quite. Please look at code below:
#include <string>
std::string && foo (void)
{
std::string message ("Hello!");
return std::move (message);
}
void bar (const std::string &message2)
{
if (message == "Bye Bye!")
return;
}
int main ()
{
bar (foo ());
}
Reference message2 is last owner of original message object returned by foo(), right?
we know algorithm how reverse array of n integers
for (int i=0;i<n/2;i++){
swap(a[i],a[n-1-i]):
}
is this method better according the speed of algorithm or not because swap using xor is more fast then in other method
here is code
public class swap{
public static void main(String[]args){
int a[]=new int[]{2,4,5,7,8,11,13,12,14,24};
System.out.println(" array at the begining:");
for (int i=0;i<a.length;i++){
System.out.println(a[i]);
}
for (int j=0;j<a.length/2;j++){
a[j]^=a[a.length-1-j];
a[a.length-1-j]^=a[j];
a[j]^=a[a.length-1-j];
}
System.out.println("reversed array:");
for (int j=0;j<a.length;j++){
System.out.println(a[j]);
}
}
}
//result
array at the begining:
2
4
5
7
8
11
13
12
14
24
reversed array:
24
14
12
13
11
8
7
5
4
2
Is there a method to detect the value of a image rgb that is blury?
I simply want to store the blury value of my image in a variable called blury value? Is there a dedicated function?
%image1 which is rgb is stored in variable img1
img1 = imread('102.jpg');
% conversion to grayscale stored in img1_grey variable
img1_grey = rgb2gray(img1);
blury_value = function_matlab(img1)
I have value in 1 string for particular key.
but NSUserDefault class method doesn't work properly and it doesn't set object of a string forkey .
in short setobject forkey method is not working of NSUserDefault class.
why is it so?
i have two lists:
List<comparerobj> list_c = new List<comparerobj>();
List<comparerobj> list_b = new List<comparerobj>();
i'm filling lists somehow
then i'm trying to find elements in list_b which list_c doesnt contain:
foreach (comparerobj b in list_b)
{
bool lc = !list_c.Contains(b);
if (lc != true)
{
data.Add(b);
}
}
but for any b i'm getting that lc = true. what am i doing wrong?
I am trying to build a search functionality which at a high level works like this.
1 - I have a Search model, controller with a search_set action and search views/partial to render the search.
2 - At the home page a serach form is loaded with an empty search object or a search object initialized with session[:search] (which contains user search preferences, zip code, proximity, sort order, per page etc). This form has a post(:put) action to search_set.
3 - When a registered user performs a set the params of the search form are collected and a search record is saved against that user. If a unregistered user performs a search then the search set action simply stores the params in the session[:search]. In either case, the search is executed with the given params and the results are displayed. At this point the url of in the location bar is something like..
http://localhost:3000/searches/search_set?stype=1
At this point if the user simply hits enter on the location bar, I get an error that says "No action responded to show" I am guessing because the URL contains search_set which uses a put method and even though I have a search_show (:get) action (which simply reruns the search in the session or saved in the database) does not get called.
How can I handle this situation where I can route a user hitting enter into the location bar to a get method?
If this does not explain the problem , please let me know I can share more details/code etc.
Thanks!
I am trying to run cimyadmin(http://cimyadmin.net/) but i am getting a lot of helper depreciation errors and after looking around the web for answers i am convinced its a php issue.Is there a way to run php 5.0.2 or earlier but not less than php 5 code on latest distributions of php.
I have a view that only has a button UIButton. First time clicking the button will draw a square above the button and the second time will replace the square with a circle.
I need some help on writing the controller code. Please guide me to the right path. Thanks
Hi guys,
I have this thing that i need to do and some advices will be greatly appreciated.
I have a Sql server table with some phone calls.For each phone call i have the start and end time.
What i need to accomplish: a stored procedure which for a certain period of time, let's say 5 hours at a x interval, lets say 2 minutes returns the number of connected calls.
Something like:
Interval Nr of Calls Connected
01-01-2010 12:00:00 - 01-01-2010 12:05:00 30
01-01-2010 12:05:01 - 01-01-2010 12:10:00 10
.............
Which will be the fastest way to do that? Thank you for your help
I'm a programmer trying to learn some css and I've already run into a stumbling block.
I have the following HTML:
<div class="container">
<div class="span-24 last">
Header
</div>
<div class="span-4">
Left sidebar
</div>
<div class="span-16">
<div class="span-8">
Box1
</div>
<div class="span-4">
Box2
</div>
<div class="span-4 last">
Box3
</div>
<div class="span-16 last">
Main content
</div>
</div>
<div class="span-4 last">
Right sidebar
</div>
<div class="span-24 last">
Footer
</div>
</div>
In my css I have the following:
body {
background-color:#FFFFFF;
}
div.container {
background:url(/images/bck.jpg);
}
I just want to display an image for the background area for the container div but nothing shows up. If I remove the background section from the css and add background-color:#000000; then I see a black background for the container div.
What am I overlooking?
here is task
How many ways are there to choose from the set {1, 2, . . . , 100} three distinct
numbers so that their sum is even?
first of all sum of three numbers is even if only if
1.all number is even
2.two of them is odd and one is even
i know that
(n) = n!/(k!*(n-k)!
(k)
and can anybody help me to solve this problem
ia have meet following problem
suppose we have sorted array of size 2^k-1 where k is given number we should copy this array into heapsearch array b the elements in odd positions of a go in order into last half of the positions of b positions congruent to 2 modul0 4 go into b's secodn quarter and so on this is not homework and please nobody tag it as homework it is from programming pearls please any ideas
i have a class:
template<class T>
class matrix
{
private:
int COLS,ROWS;
public:
inline matrix(int r,int c){
this->COLS=r;
this->ROWS=c;
}
template<class T2>
friend ostream& info(ostream& os);
};
i tried in so many ways to implement the info class.but none is succeed.
i want to use it in main function
Matrix<int> M(10,20);
cout<<info<<M;
i want to out put the Matrix class's cols, and rows information.
i have tried so many time in implementing the friend class info, but failed.
any one can tell me how can do it?
I have been asked in an interview, To write a sql query which fetches the first three records with highest value on some column from a table. i had written a query which fetched all the records with highest value, but didnt get how exactly i can get only first three records of those.
could you help me in this.
thanks.
I want to detach the custom event but could not detach. Please find below I am using -= to detach the event. I assume after this, TextChanged2 method should not be invoked as I have unregistered the event. Let me know if my understanding is wrong.
public delegate void TextChangedEventHandler1(object sender, TextBoxargs ta);
public event TextChangedEventHandler1 TextChanged1;
private void textBox1_TextChanged(object sender, EventArgs e)
{
this.TextChanged1 -= new TextChangedEventHandler1(TextChanged2);
TextChanged2(sender, e);
}
public void TextChanged2(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text.ToUpper();
}