VEXcode Pro V5-ൽ ഒരു മൂല്യം തിരികെ നൽകുന്നതിന് ഒരു ഫംഗ്ഷൻ എഴുതുന്നു.

The VEX Visual Studio Code Extension has replaced VEXcode Pro V5, which is now end-of-life.

VEXcode Blocks and VEXcode Text remain actively developed and supported for all VEX platforms.

സാമ്പിൾ: ഒരു ലളിതമായ ഏറ്റവും വലിയ പൊതു ഡിനോമിനേറ്റർ (ജിസിഡി) ഫംഗ്ഷൻ (യൂക്ലിഡ് അൽഗോരിതം ഉപയോഗിച്ച്)

ഒരു ലളിതമായ ലൂപ്പ് ഘടനയിൽ ഇത് എങ്ങനെ ഉപയോഗിക്കുന്നുവെന്ന് താഴെ കൊടുത്തിരിക്കുന്ന സാമ്പിൾ വ്യക്തമാക്കുന്നു.

ഉപയോക്തൃ-നിർവചിത ഫംഗ്ഷൻ ഉപയോഗിക്കാതെ:

int main() { 
  int remain = 1;
  int a1, b1, a2, b2;
  vexcodeInit();
  a1 = a2 = 20;
  b1 = b2 = 64;
  while(remainder > 0){
    remainder = a1 % b1;
    a1 = b1;
    b1 = remainder;
  }
  Brain.Screen.printAt(5, 60, "GCD ( %d, %d ) = %d", a2, b2, a1);

  a1 = a2 = 60;
  b1 = b2 = 200;
  while(remainder > 0){
    remainder = a1 % b1;
    a1 = b1;
    b1 = remainder;
  }
  ബ്രെയിൻ.സ്ക്രീൻ.പ്രിന്റ്അറ്റ്(5, 60, "ജിസിഡി ( %d, %d ) = %d", എ2, ബി2, എ1);
}

ഒരു ഉപയോക്തൃ-നിർവചിച്ച ഫംഗ്ഷൻ ഉപയോഗിക്കുന്നു:

int getGCD(int a, int b){
  int remain = 1;
  while(remainder>0){
    remain = a % b;
    a = b;
    b = remain;
  }
  return a;
}

int main() { 
  vexcodeInit();
  Brain.Screen.printAt(5, 60, "GCD ( %d, %d ) = %d",getGCD(20, 64));
  Brain.Screen.printAt(5, 60, "GCD ( %d, %d ) = %d",getGCD(60, 100));
}

കോളർ ഫംഗ്ഷൻ main() ൽ നിന്നുള്ള ലോജിക് ഫ്ലോയുടെ ക്രമം ഇവിടെ കാണിക്കുന്നു:

മാതൃക: ഒരു സംഖ്യാഗണത്തിന്റെ ശരാശരി കണക്കാക്കൽ

ഫ്ലോട്ട് doAverage(int n1, int n2, int n3){
  ഫ്ലോട്ട് ശരാശരി = (n1 + n2 + n3)/3;
  റിട്ടേൺ ശരാശരി;
}

int main() { 
  int n1, n2, n3;
  Brain.Screen.print("ശരാശരി(%d, %d, %d) = %d", 10, 20, 30); 
  doAverage(10, 20, 30);

  n1=10; n2=20; n3=40;
  Brain.Screen.print("ശരാശരി(%d, %d, %d) = %d", n1, n2, n3);
  doAverage(n1, n2, n3);
}

സാമ്പിൾ: വേരിയബിൾ എൻകോഡേഴ്‌സ് മൂല്യത്തോടെ മുന്നോട്ട് പോകാൻ ഒരു റോബോട്ടിനെ പ്രാപ്തമാക്കുക.

void reportMotionValues(){
  Brain.Screen.printAt(5,100, "%8.2lf%8.2lf%8.2f",
    LeftMotor.position(rev),
    LeftMotor.position(deg));
}

void goStraight(float totalEnc, float vel){
  LeftMotor.resetPosition();
  LeftMotor.setVelocity(50.0, ശതമാനം);
LeftMotor.spinToPosition(totalEnc, deg, true); return; } int main() { int enc=1000; // >0: forward, <0: backward vexcodeInit(); for(int i=0; i<10; i++){ enc *= -1; goStraight(enc, 100); Brain.Screen.printAt(5,60, "Done"); reportMotionValues(); //ഈ പ്രവർത്തനങ്ങൾ കാണുന്നതിന് മാത്രമാണ് ഈ കാലതാമസം ഇവിടെ നൽകിയിരിക്കുന്നത്. //ഇവിടെ ഒരു കാലതാമസം വരുത്തേണ്ടതില്ല. കാത്തിരിക്കുക(2000, എംസെക്കൻഡ്); } }

നിങ്ങൾക്ക് കാണാനാകുന്നതുപോലെ, റോബോട്ടിനെ മുന്നോട്ടും പിന്നോട്ടും വേരിയബിൾ തവണ പോകാൻ പ്രാപ്തമാക്കുന്നത് അസാധ്യമാണ്; കാരണം റൺ-ടൈമിൽ മാത്രമേ ഇത് നിർണ്ണയിക്കാൻ കഴിയൂ.

For more information, help, and tips, check out the many resources at VEX Professional Development Plus

Last Updated: