Jump to content
GIGN Forum

Palīdzība C saistībā


dextOr
 Share

Recommended Posts

Sveiki!

Man skolā iedeva šo uzdevumu, kas ir jāuzprogrammē C valodā. Es saprotu, ka uzdevums droši vien ir smieklīgi viegls priekš daudziem no jums, bet es, kā programmēšanas iesācējs vēlētos saņemt palīdzību.

Ja saproti uzdevumu un vari palīdzēt, tad lūdzu raksti. (Protams, es pats vēlos izprast visu, tā kā, vēlams uzreiz atbildi nesakiet, bet labāk dodiet hintus, ko man darīt)

Paldies!

post-14390-0-03911500-1380462675_thumb.jpg

Link to comment
Share on other sites

Ud ir sprieguma kritums uz diodi. Tev jauzraksa progama kura sak ar Ud = 0, un pakapeniski to palielina. Palielinot Ud, palielinasies Id (strava uz diodi) un samazinasies Ir (strava uz pretestibu, jo samazinas caur to plustosais spriegums).

Viena momenta Id bus sasniedzis Ir vertibu. Acimredzot tas saja uzdevuma tiek uzskatits par "equalibru", un varam uzskatit, ka esam atradusi Ud vertibu.

kods bus apmeram sads

while (ir - id > eps)

{

ud = ud + 1ma;

ir = pretestibas formula;

id = diodes formula;

}

Beefs

Edited by 0xDEAD BEEF
  • Like 1
Link to comment
Share on other sites

Mana doma ir apmēram šāda:

while (Ud = (n)*(0.1mV))

while (Ir - Id < 1microAmp)

{

User inputs positive values for Uin and R;

Ud = calculation #1

Id = calculation #2

print Ud and R on screen

}

Protams, iekš calculation #1 un #2 ir vēl pretestība, bet es uztraucos par to, kā programma reaģēs uz to, ka iznākums ir range of values nevis tieši viena konkrēta.

Link to comment
Share on other sites

  • 2 weeks later...

#define IS 10e-11

#define MICROAMP pow(10, -6)

int main() {

/*Function declarations:*/

float fUd, fUin, fR, fIr, fId;

char repeat = 'y';

while (repeat == 'y') {

/*Asks the user to give the value for the Internal Voltage (in Volts):*/

printf("Enter a positive value for the internal voltage (in Volts): ");

scanf("%f", &fUin);

/*Asks the user to give the value for the Resistance (in Ohms):*/

printf("Enter a positive value for the resistance (in Ohm): ");

scanf("%f", &fR);

fUd = 0;

fId = IS * (exp(fUd / 25) - 1);

fIr = (fUin - fUd) / fR;

while ((fIr - fId) > MICROAMP) {

fId = IS * (exp(fUd / 25) - 1);

fIr = (fUin - fUd) / fR;

fUd = fUd + 0.1;

printf("Ud = %6.1f millivolts and Id = %6.3f milliamps \n", fUd, fId);

}

printf("Do you want to run the program again? [y/n]:");

scanf(" %c", &repeat);

}

return 0;

}

Lūk, kas iznāca, bet nezinu, kur ir kļūda.... Kkas nav tā, kā vajag.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...