PCDVD¼Æ¦ì¬ì§Þ°Q½×°Ï

PCDVD¼Æ¦ì¬ì§Þ°Q½×°Ï (https://www.pcdvd.com.tw/index.php)
-   ¤C¼L¤K¦Þ²§¨¥°ó (https://www.pcdvd.com.tw/forumdisplay.php?f=12)
-   -   [¨D§U]½Ö·|C++.... (https://www.pcdvd.com.tw/showthread.php?t=686619)

timas 2007-01-09 07:25 AM

¤Þ¥Î:
§@ªÌmorphine0821
§AªB¤Í... ¨kªºÁÙ¤kªº¡H¡H


«¢«¢«¢¡@¡@¡@¡@¡@¡@¡@¡@¡@

lyl 2007-01-09 08:11 AM

«ØÄ³³o¼ËªºªB¤Í, ¤£­n¥h·d¸ò§Þ³N¦³Ãöªº¸ê°T¤u§@,
¦n¦n½m¥´¼L¯¥¯à¤O, ·d¤£¦n¥H«á´NÅܦ¨¦ÑÁó¤F :D

crazyjack 2007-01-09 08:46 AM

¤Þ¥Î:
§@ªÌpc
§Ú¦b¬ü°ê©Àªº¾Ç®Õ´NÅ¥¾Ç§Ì»¡¹L¥L¨º¯Z¤W¦³¤H¦n¹³­ì¥ý¬O©À¥øºÞÁÙ¬O¤°»ò¬ì¨tªº¡A
¶]¨Ó¥Ó½Ð¸ê¤u©Ò´NŪ¡A¨º­Ó¤H¤]¬O¨S¼g¹Lµ{¦¡¡A·Q§ä¨º¨Ç¤£¥Î¼gµ{¦¡project


§Ú¥H¬°¥u¦³§Úªº¾Ç®Õ¦³³oºØ¤H....= =|||
§ó§èªº¬O³sGoogle´N¦³µª®×ªº³£¤£·| ÁÙ­n°Ý¤H.....

gt3a01 2007-01-09 09:13 AM

¤Þ¥Î:
§@ªÌpc
§ÚÁÙ¥H¬°¬O³æ¯Âªºdebug«¨¡A¨S·Q¨ì²V¦¨³oºØ¦a¨B¡A­n§Ú­Ì±qÀYÀ°¨ì©³¡H¡H.............
¤£¹L¸Ü»¡¦^¨Ó¤F¡A¬Y¨Ç¾Ç®Õ¹ï©ó¸ê¤u³o¬ì¨tÅãµM¤J¾Ç¼Ð·Ç©ñ±o®¼§Cªº¡A
§Ú¦b¬ü°ê©Àªº¾Ç®Õ´NÅ¥¾Ç§Ì»¡¹L¥L¨º¯Z¤W¦³¤H¦n¹³­ì¥ý¬O©À¥øºÞÁÙ¬O¤°»ò¬ì¨tªº¡A
¶]¨Ó¥Ó½Ð¸ê¤u©Ò´NŪ¡A¨º­Ó¤H¤]¬O¨S¼g¹Lµ{¦¡¡A·Q§ä¨º¨Ç¤£¥Î¼gµ{¦¡project¡A¥u­n§@¬ã¨sªº½Ò¨Ó©À¡A
¥i¬O°ò¥»¤W´X¥G¬O¤£¥i¯à¡A¦]¬°¨t¤W¤@¤j°ï¥²­×½Òªºproject³£¬O­n¼gµ{¦¡ªº¡A
¦óªp¸ê¤u©Òªº½Ò¤£·|­«·s±Ð¾Éµ{¦¡»y¨¥«ç»ò¼g¡A¦pªG¥ý«e¤j¾Ç©Ò­×©Î¬O¤u§@¤W¦³¿i½m¨ìcodingªº¸Ü¡A
®Õ¤ºªº§@·~·|«Ü®e©ö¤W¤â¡B¾r»´´N¼ôªº¡A¦pªG¨S¤@ÂI°ò¦´N¨Ó­×³oÃþ½Òµ{ªº¸Ü¡A
«OÃÒ·|­×±o«Üµh­W¡A¦Ó¥B«ÜÃø§ä¨ì¤£¥Î¼gµ{¦¡ªº½Ò¨Ó­×ªº¡C


¤£¬O¸ê¤uªº..
¤]¤£ª¾¹D¬O¤£¬O²V..@@
¥u¬O..§Ú¨ä¹ê¤]¦³¾Ç¹LC++..¦ý¬O¨S·Q¨ì¬O¦p¦¹Ãøªº...orz..

¥H«e¤]´¿¸gC++ ³Q³s·í4¾Ç´Á...( :cry: §Ú¯u¬OC++¥Õè..)

gt3a01 2007-01-09 09:17 AM

¤Þ¥Î:
§@ªÌcrazyjack
§Ú¥H¬°¥u¦³§Úªº¾Ç®Õ¦³³oºØ¤H....= =|||
§ó§èªº¬O³sGoogle´N¦³µª®×ªº³£¤£·| ÁÙ­n°Ý¤H.....


google¯uªº¦³»ò@.@....
¦n®£©ÆªºGoogle......
´N¦p¦P§Ú¥t¤@­ÓªB¤Í¥ÎGoogle¬d¸ß¨ì¨ä °ê¤p¦P¾Ç¤@¼Ë..

¯u¬O±jªÌ§ÚªB¤Í Äò¶°XD...

anyway..¹ê¦b¬O«Ü·PÁ¤j®a... :cry:

pc 2007-01-09 09:45 AM

¤Þ¥Î:
§@ªÌcrazyjack
§Ú¥H¬°¥u¦³§Úªº¾Ç®Õ¦³³oºØ¤H....= =|||
§ó§èªº¬O³sGoogle´N¦³µª®×ªº³£¤£·| ÁÙ­n°Ý¤H.....

¬ü°ê«Ü¦h¾Ç®Õ¤£½×¬O¤½¥ßÁÙ¬O¨p¥ßªº¡A¥u¬°¤FÁÈ¿ú¡A©Û¦¬¤F¤@°ï¾Ç¥Í¶i¨Ó¡A
¤]¤£ºÞ³o¨Ç¾Ç¥Í¨ì©³¬O¤£¬O°÷¸ê®æ....... :jolin: :jolin: :jolin:

»È¦â¾Ô¨®Âí»î¦± 2007-01-09 10:12 AM

¸Ü»¡
§Ú±MÃD¤]¬OC
ªá¤F¤@±i¤pªB¤Í...............

½Ö§ä§Ú 2007-01-09 08:12 PM

°Ñ¦Ò¥Î..¨ä¥L¾a§AªB¤Í¦Û¤vÅo..
 
¥[ªo¡A
§O¿éµ¹®aùØÃÛ¼o§÷...

¥N½X:
#include <iostream.h>
#include <math.h>

float calculate_Sx(float Vinit, float degree, float timeSlice);
float calculate_Sy(float Vinit, float degree, float Height,float timeSlice);
void  receiveInputData(float &Vinit,float &height, float &degree);
float G=9.8;

struct ObjectInfo // ª«Å骺®É¶¡¡A®y¼Ð 
{
       float currentTime;
       float x;
       float y;
};
      
void receiveInputData(float &Vinit,float &height,float &degree)
{
     cout<<"©ßÅé¹B°Ê\n" ;
     cout<<"½Ð¿é¤Jªì©l³t«×(¥H¯BÂI¼Æ©Î¾ã¼Æ)¡G";
     cin>>Vinit;
     cout<<"§A¿é¤Jªºªì©l³t«×¬°¡G"<<Vinit<<endl;
     cout<<"½Ð¿é¤Jªì©l°ª«×(¥H¯BÂI¼Æ©Î¾ã¼Æ)¡G";
     cin>>height;
     cout<<"§A¿é¤Jªºªì©l°ª«×¬°¡G"<<height<<endl;
     cout<<"½Ð¿é¤J©ßÅ騤«×(¥H¯BÂI¼Æ©Î¾ã¼Æ)(³æ¦ì¡G«×)¡G";
     cin>>degree;
     cout<<"§A¿é¤Jªº©ßÅ騤«×¬°¡G"<<degree<<endl;     
 }
 
float calculate_Sx(float Vinit, float degree, float time)
{
      float Sx=0;
      float radian=0;

      radian = (3.14*degree)/180.0;
      Sx = Vinit*cos(radian)*time;

      return Sx;
}

float calculate_Sy(float Vinit, float degree, float height,float time)
{
      float Sy=0;
      float radian=0;
      
      radian = (3.14*degree)/180.0;
      Sy = height + Vinit*sin(radian)*time - 0.5*G*pow(time,2.0);
      
      if(Sy <= 0) return 0;
      
      return Sy;
}

bool isItOnAir(float currentSy)
{
     if (currentSy <= 0) 
     {
     return false;
     } 
     else
     {
     return true;
     }
}

float onAirTime(float Vinit, float degree, float height,float timeSlice)
{
      float elapseTime=0;
      float Sy=0;

     do
     {
      elapseTime = elapseTime+timeSlice;
      Sy = calculate_Sy(Vinit,degree,height,elapseTime); 
      }
      while(isItOnAir(Sy)); // ©Î while(Sy > 0) ;

      return elapseTime;
}


int main(void)
{
    float Sx=0;
    float Sy=0;
    float time=0;
    float degree=0;
    float Vinitial=0;
    float height=0;
    float timeSlice = 0.1;
    float currentTime=0;
    float elapseTime=0;
    
    int arraySize=0;
    int index=0;
    
    receiveInputData(Vinitial,height,degree); // ¿é¤J¤¶­± 
    
    elapseTime = onAirTime(Vinitial,degree,height,timeSlice); // º¢ªÅ®É¶¡ 
    elapseTime = elapseTime + 3; //¸¨¦a«ùÄò3¬í¹B°Ê 
     
    arraySize = (int)(elapseTime/timeSlice);

    ObjectInfo *objectInfoArray;
    
    // ªì©l¤Æ¹B°Êª«Å骺Àx¦s¸ê°T ¡A°t¸m°O¾ÐÅé 
    objectInfoArray = (ObjectInfo *)malloc(arraySize*sizeof(ObjectInfo));
  
    do
    {
      currentTime = currentTime+timeSlice;
      Sx = calculate_Sx(Vinitial,degree,currentTime);
      Sy = calculate_Sy(Vinitial,degree,height,currentTime); 
      objectInfoArray[index].currentTime = currentTime;
      objectInfoArray[index].x = Sx;
      objectInfoArray[index].y = Sy;
      index++;
    }
    while(isItOnAir(Sy)); //©Î while(Sy > 0);
    
    // continue move 3 seconds
    float onGroundTime = currentTime;  
    do
    {
     currentTime = currentTime+timeSlice;
     Sx = calculate_Sx(Vinitial,degree,currentTime);
     Sy = calculate_Sy(Vinitial,degree,height,currentTime); 
     objectInfoArray[index].currentTime = currentTime;
     objectInfoArray[index].x = Sx;
     objectInfoArray[index].y = Sy;
     index++;     
    }while((onGroundTime+3) >= currentTime);
    
    //¿é¥X¤¶­± 
    for(int i=0;i<arraySize;i++)
    cout<<i<<",time="<<objectInfoArray[i].currentTime<<",(x="<<objectInfoArray[i].x<<",y="<<objectInfoArray[i].y<<")"<<endl;

   return 0;  
}


ªº§Ú...­ü...


©Ò¦³ªº®É¶¡§¡¬°GMT +8¡C ²{¦bªº®É¶¡¬O02:00 AM.

vBulletin Version 3.0.1
powered_by_vbulletin 2025¡C