dextOr Posted September 29, 2013 Report Share Posted September 29, 2013 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! Link to comment Share on other sites More sharing options...
0xDEAD BEEF Posted September 29, 2013 Report Share Posted September 29, 2013 (edited) 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 September 29, 2013 by 0xDEAD BEEF 1 Link to comment Share on other sites More sharing options...
dextOr Posted October 1, 2013 Author Report Share Posted October 1, 2013 Paldies, pats tikko profesoram uzprasīju, viņš man līdzīgus hintus iedeva, kas man atļāva sameklēt vajadzīgo info. Tagad tikai jāuzcepj proga Link to comment Share on other sites More sharing options...
dextOr Posted October 5, 2013 Author Report Share Posted October 5, 2013 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 More sharing options...
0xDEAD BEEF Posted October 7, 2013 Report Share Posted October 7, 2013 Tu varetu daudz nedomat pie tik vienkarsa uzdevuma, bet vienkarsi to uzprogrammet! Beefs Link to comment Share on other sites More sharing options...
dextOr Posted October 15, 2013 Author Report Share Posted October 15, 2013 #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 More sharing options...
dextOr Posted October 15, 2013 Author Report Share Posted October 15, 2013 Ja es ievietoju konversāciju no voltiem uz milivoltiem Uin = Uin * 1000, tad it kā programma iet, bet man liekas, ka kalkulācija nav pareiza Link to comment Share on other sites More sharing options...
0xDEAD BEEF Posted October 16, 2013 Report Share Posted October 16, 2013 Lol. Kapec tu neprasi jautajumu par nepareizu kalkulaciju tam calim, kursh tev shito programmu uzrakstija?! Beefs Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now