hajiakhundov 0 Newbie Poster

Wouldn't that trap high at 1 and low at 0? Perhaps 1, 1 are what you meant as starting vars.

yeah, its 1 1.
But now the problem is the long. This would work only till n = 46.
What if I wand fib (100)? Any suggestions?
Regards

hajiakhundov 0 Newbie Poster
hajiakhundov 0 Newbie Poster

why don't you make your own function using <ctime>? Just let it loop for a second every time.

Yeah, Tigran, that was a good idea.
I did something like

Time b,c; // class Time,  Constructs a Time object that is set to 
  //    the time at which the constructor executes.

// the rest is pretty clear.

int t1 = b.get_seconds(); // seconds at that time. when b was created;
int t2;
 while (true)
 {
         Time c;  t2 = c.get_seconds(); if (t2==t1+5) break; // creates //new c each time, (+5) indicates 5 seconds delay. 
 };

But anyways, I would like to know how Timer works in Visual c++.
Thanks.

hajiakhundov 0 Newbie Poster

MrSpigot, this is not working either :(

using namespace System::Threading;
Thread::Sleep(1000);
hajiakhundov 0 Newbie Poster

The code below seems to be working. But is it alright to do it this way? What is the difference between system::string or a normal string? Or between a * char?

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {

				 String^ b;
				 b = textBox1->Text;
}

However, this does not work..

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {

				 String^ b, c;
				 b = textBox1->Text;
				 c = textBox2->Text;
				 foo a(b, c);
				
			 }

Could someone please explain me how can I fix this. Thanks.

hajiakhundov 0 Newbie Poster

Yeah, from line 38 everything seems to be messed up. Could you please explain more about the binomial number please. What exactly are you supposed to find?

hajiakhundov 0 Newbie Poster

What do you mean by "it doesn't work"?

Well, it should change the Text of label1 from 1 to 9, with a 1 second interval. However it does not, it shows me, a 9 right away, when I click the button.

hajiakhundov 0 Newbie Poster

How do you know Sleep() doesn't work?? Recall the parameter is milliseconds -- there are 1000 milliseconds in one second.

Yeah, I know. It is still not working. Well, it does work when I do a console application, but not when I do it in the Forms app.


The following does not work:

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {

				 for (int k = 0; k < 10; k++)
				    {
				   	 Sleep(1000);
					  label1->Text = Convert::ToString (k);
				    }
				 
			 }
hajiakhundov 0 Newbie Poster

Hello.

Can someone please tell me how can I get the Text from the textBox, and store it into a string for instance.

To be more specific,

I have a function:

foo (const char* str, const char *strat);

And when I call it, I want it to take the the parameters from two different textBox 'es.

How can I do that?

Thanks in advance. :)

hajiakhundov 0 Newbie Poster

Hi everyone.

I am creating a small windows form application using Visual C++; and I would need to delay a loop by a second. Sleep() doesn't work.(Not sure why) Is there a way I can use the timer? Any suggestions on how can I do that?

Thanks in advance. :)

hajiakhundov 0 Newbie Poster

Narue, thanks a lot! It worked finally :)

hajiakhundov 0 Newbie Poster

I looked around a bit, what I found out is that we actually need to convert an int to System::String. Who can help me with that?

hajiakhundov 0 Newbie Poster

vidmaa, this doesn't work with Visual.


Clinton, it does not work in my situation. I am sure it is going to work if I do it as console application. However it does not work with the Forms :(

hajiakhundov 0 Newbie Poster

You're welcome :)

hajiakhundov 0 Newbie Poster

here, check this out:

http://msdn.microsoft.com/en-us/library/fxky5d0w(VS.80).aspx

hajiakhundov 0 Newbie Poster

:-O
yes, 2^2 is 2*2, but that is the only case :)

Note that 3^2 does not equal to 3*2 :)

Moreover, why would ^ be created if it's the same as *?? ;)

plus, when you are squaring something, you always get rid off the negative sign, however, if you multiply 2 by some negative number, you will get a negative number. And a negative number under a square root gives you a complex number. That is actually why you are getting the #IND as an answer.

hajiakhundov 0 Newbie Poster

You wrote that

distance = sqrt( (x1-x2)^2) + ((y1-y2)^2).. .

and you are multiplying it by 2, instead of doing a power to 2. That is why you are getting a wrong answer.

double distance(double x1,double x2,double y1,double y2)
{
return sqrt((2*(x1-x2))+(2*(y1-y2)));
}

instead you should have

double distance(double x1,double x2,double y1,double y2)
{
return sqrt((pow((x1-x2),2))+(pow((y1-y2),2)));
}
:)

hajiakhundov 0 Newbie Poster

Hello Everyone.
I am creating this Windows Forms Application using Visual Studio.
Basically, in order to do what I want to do, I need to use an integer, and that integer needs to be converted into a string in order to change the label text, when pushing the button. However, using static_cast, like I did in the code below gives me " error C2061: syntax error : identifier 'string' ". :( I have included <string> on top of the file.
What shall I do in order to fix this problem and make this run? Any suggestions?

Thanks in advance. :)

#pragma once
#include <string>


namespace testingforms {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;
///////////////////////////////////////
// Everything that is created by default
// when creating a Windows Forms Application
// I just deleted it, I don't think it is that much of a concern.
//////////////////////////////////////


	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e)
			 {
			
				 int a;
				 a=5;
				 label2->Text = static_cast<string>(a); //right here
			 }


}
hajiakhundov 0 Newbie Poster

ok, i got what you saying)
but note, when people google these kind of things, they get the links to this kind of threads... and I wouldn't propably figure out how to shorten this program using STL. :)
So, I think that everything is cool)
take care.

hajiakhundov 0 Newbie Poster

And I'd like to point out that hajiakundov and siddhant3s have both not helped confused! to learn. Giving answers only gets the assignment done, but does not promote learning how to do the assignment.

Please read the stickies at the top of this forum.

Vmanes >> The thread was posted on Nov 26th, 2006... I think he completed the assignment by today? Don't you think so? :)

siddhant3s>> Thanks man, I'll take a look at your code ;)

hajiakhundov 0 Newbie Poster

Use this to figure out if the number (string) is a palindrome or not...
the rest, the file handling, try doing it by yourself, it is very easy.. if you have troubles doing that, let me know. :icon_wink:

#include <iostream>
#include <string>
using namespace std;


int main ()
{   
    int x;
    string n,mem,inverse="";           //inverse is empty at the begining..
    cin >> n;                     // enter the number we want to check if it is polindrome or not
    mem=n;                 // store n in mem,, you will needed later...
    x=n.size();            // get the size of the string and store it in the int x

   while (x>0)  
   {
       inverse=inverse+n.substr(x-1);             // get's the last digit and puts it in the new string 'inverse'
       n.erase(x-1,x);                   //erase the last digit... that's why we needed 'mem'
           x--; // loop stuff
   }

    cout << inverse << endl;                // not necessary. 

   if (mem == inverse)                 // if the entered string is the same as the inverse, then it is "palindromic"
                                           // some examples...  123321 or ada etc.                                                                                 
   {
       cout << "The number is palindromic";
   }


    return 0;
}

/*****************************************************************
**The program reverses the string that was inputed by the user.
** tells us if it is polindromic or not.
**Haji Akhundov. (c) All rights reserved.:)
******************************************************************/