Jump to content

  • Log In with Google      Sign In   
  • Create Account

MotorBully

Member Since 24 Mar 2012
Offline Last Active Feb 03 2013 11:01 PM

Topics I've Started

How to add a line to the two dimensional array?

03 April 2012 - 07:27 AM

The question is the same as topic.Here is the first code
#include <iostream.h>
void main()
{
int m = 3 ,n =2,i,j;
int **data = new int*[m];
for(i=0;i<m;i++)
{
  data[i] = new int[n];
}
for(i =0;i<m;i++)
{
  for(j= 0;j<n;j++)
  {
   data[i][j] = i*j;
  }
}
for(i=0;i<m;i++)
{
  for(j=0;j<n;j++)
  {
   cout<<"data["<<i<<"]["<<j<<"]="<<data[i][j]<<"\n";
  }
}
then ,i want to add a line to the "array"(a array) and give the number to this line which is
m = m+1;
   for(i=0;j<n;j++)
   {
	 data[m][j]=(m+2)*j;
   }
Is that adding "m += 1" to the code right?

Is there any master be good at Actionscript in Flash ?

26 March 2012 - 07:14 AM

Collision Detection is very important to the Flash!
Now , i have been making a game about basketball,but there is a big skill problem blocked my game development which is about the collision detection algorithm of two balls.
I have defined the name "ball" and "balll".They are all from Ball Class.Ball Class have got the Attribute ,such as ball.vx,ball.vy,ball.radius,ball.v;

Here is my code
  sina = (ball.y - balll.y)/(ball.radius + balll.radius);
  cosa = (ball.x - balll.x)/(ball.radius + balll.radius);
distance = Math.sqrt((ball.x - balll.x)*(ball.x - balll.x) +(ball.y - balll.y)*(ball.y - balll.y));
if (distance <= (ball.radius +balll.radius))
{
  v = Math.sqrt(ball.vx * balll.vx + ball.vy * balll.vy);
  ball.x = balll.x+cosa*(ball.radius+balll.radius);
  ball.y = balll.y+sina*(ball.radius+balll.radius);
  ball.vy *=  0.8;
  ball.vx *=  0.4;
  ball.vx = (v * cosa);
  ball.vy = (v * sina);
  balll.vx =  -(v * cosa);
  balll.vy =  -(v * sina);
}
Now , if the speed of ball is so fast , two ball will l overlapped together and they will not move or move slowly.How can i solve this problem?

I'm new hear,help me in C language(not C++)

24 March 2012 - 02:05 PM

This is my first time to public a topic!I really want to exchange the programming technologe with others ,but i have great trouble in talking with others.Because my english is very poor,now,i'm taking a dictionary with my left hand,right hand is on(on or in??damn it) the keyboard,looked ridiculous.I am really want to make friend with people who likes talk with me.Althoule??Althougle?(damn it)(what is "SuiRan")Oh , my god,let me find this word,that..........is "Although",ha!Although the language problem is very bad to me,but the computer is the same, the computer language is the same,such as the C++language.

Now !Show me code where include my question.
#include <stdio.h>
#include <math.h>
void ERROR();
double main()
{
float I;
float S;
int month;
RETURN1:
printf("Input the monthly interest rate(0~100):\n");
scanf("%f",&I);
if(I<=100&&I>=0){}
else
{
ERROR();
goto RETURN1;
}
RETURN2:
printf("Input total deposits(0~5000000000):\n");
scanf("%f",&S);
if(S<=5000000000&&S>=0){}
else
{
ERROR();
goto RETURN2;
}
RETURN3:
printf("Input storage for several months(0~3600):\n");
scanf("%d",&month);
printf("\n");
if(month<=3600&&month>=0){}
else
{
ERROR();
goto RETURN3;
}
double CS;
I = (I/100)+1;
CS = S*(pow(I,month));
printf("%d month later!You have :%f\n",month,CS);
printf("CALCULATING HAS BEEN CLOSED!!!\n");
return 0;
}
void ERROR()


{
printf("Error,Input again!!!\n");
};


The question has come!
if i input not a numer but an Char just like ' a ',The programe will cout the "Error,Input again!!!" again and again, i use the "if "and"else",
"a" is truely out of the range,how can i do now.
just like ....



Input the monthly interest rate( 0 ~100)
a //i input an "a",(not a number)
Error,Input again!!!
Error,Input again!!!
Error,Input again!!!
Error,Input again!!!
Error,Input again!!!
Error,Input again!!!
Error,Input again!!!
.............................. //I cannot stop it unless i close the window;
what is it?How it be that??

PARTNERS