Hurtig Hjælp!!!
Hejsa Experter!!!!Jeg har lavet lidt c programmering(jeg har fået lidt undervisning i det).
Men da jeg kun har fået meget lidt undervisning har jeg nogle store huller i min c/c++ viden...
så jeg ville være glad vis der var nogle der kunne, udfra den neden for stående text/programmering kunne smide nogle kommentare ind, så som hva gør include <iostream.h> fx og hva med cout, cin, scanf, %d, %f også videre det ville være en rigtig STOR hjælp TAK
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <math.h>
#define x 20
#define y 5
char ch;
void main(void)
{
start:
float v,a,o,w,rtot;
char tal;
float srtot,prtot;
int pm,sm,t;
clrscr(); //rens sk‘rmen
_setcursortype(_NOCURSOR); //Ingen cursor
textcolor(WHITE); //tekstfarve (hvid)
textbackground(BLUE); //baggrundsfarve (bl†)
clrscr(); //rens sk‘rmen
//hovedmenu start
printf("\n\n\t\t\t\ Lommeregner");
printf("\n\n\t\t\t\ V‘lg 1,2 eller 3");
printf("\n\n\n\t\t [1]:Udregning af:\n\t\t Sp‘nding, Modstand, Str›m og Effekt");
printf("\n\t\t [2]:Parallelforbindelse");
printf("\n\t\t [3]:Serieforbindelse");
printf("\n\n [Q]:Quit");
ch = getch();
//hovedmenu slut
switch(ch)
{
case '1': //menu 1
{
clrscr(); // rens sk‘rmen
gotoxy(x+3,y); //g† to x,y
printf("Udregning af U,I,R og P");
gotoxy(x-19,y+20);
printf("Indtast 0 hvor svaret er ukendt");
gotoxy(x,y);
cout<<"\n\nIndtast Volt: "<<endl; //printf
cin>>v; //input
cout<<"Indtast AmpŠre: "<<endl;
cin>>a;
cout<<"Indtast Ohm: "<<endl;
cin>>o;
cout<<"Indtast Watt: "<<endl;
cin>>w;
//udregninger
if((a!=0)&&(o!=0)&&(v==0)&&(w==0))
{
v = a*o;
w = a*a*o;
}
else if((a!=0)&&(v!=0)&&(o==0)&&(w==0))
{
w = v*a;
o = v/a;
}
else if((a!=0)&&(w!=0)&&(o==0)&&(v==0))
{
o = w/(a*a);
v = w/a;
}
else if((o!=0)&&(v!=0)&&(a==0)&&(w==0))
{
a = v/o;
w = v*v/o;
}
else if((o!=0)&&(w!=0)&&(a==0)&&(v==0))
{
a = sqrt(w/o);
v = sqrt(w*o);
}
else if((v!=0)&&(w!=0)&&(a==0)&&(o==0))
{
a = w/v;
o = v/w;
}
else if((a!=0)&&(o!=0)&&(w!=0)&&(v==0))
{
v = a*o;
v = w/a;
v = sqrt(w*o);
}
else if((v!=0)&&(o!=0)&&(w!=0)&&(a==0))
{
a = sqrt(w/o);
a = w/v;
a = v/o;
}
else if((a!=0)&&(v!=0)&&(w!=0)&&(o==0))
{
o = w/a*a;
o = v*v/w;
o = v/a;
}
else if((a!=0)&&(o!=0)&&(v!=0)&&(w==0))
{
w = v*a;
w = v*v/o;
w = a*a*o;
}
//udregning slut
//resultat:
cout<<"\n\tVolt = "<< v <<endl;
cout<<"\n\tAmpŠre = "<< a <<endl;
cout<<"\n\tOhm = "<< o <<endl;
cout<<"\n\tWatt = "<< w <<endl;
gotoxy(x-19,y+20);
cout<<"Tryk P† Enter For At Komme Tilbage Til Hoved Menuen";
break; //pause
}
case '2': //menu 2
clrscr(); //rens sk‘rm
gotoxy(x-19,y+20);
printf("Der Kan Max V‘lges 32767 Modstande");
gotoxy(x,y);
printf("Udregning af Parallel Forbindelse");
printf("\n\nIndtast Antal Modstande: ");
scanf("%d",&pm);
prtot = 0.0;
//udregnings metode
for(t=1;t<=pm;t++)
{
printf("Indtast Ohm %d: ",t);
scanf("%f",&o);
prtot=prtot+(1/o);
}
//resultat
printf("\nRtot= %.2f Ohm\n",1/prtot);
gotoxy(x-19,y+20);
printf("Tryk P† Enter For At Komme Tilbage Til Hoved Menuen");
break;
case '3': //menu 3
clrscr(); //rens sk‘rm
gotoxy(x-19,y+20);
printf("Der Kan Max V‘lges 32767 Modstande");
gotoxy(x,y);
printf("Udregning af Seriel Forbindelse");
printf("\n\nIndtast Antal Modstande: ");
scanf("%d",&sm);
srtot = 0.0;
//udregnings metode
for(t=1;t<=sm;t++)
{
printf("Indtast Ohm %d: ",t);
scanf("%f",&o);
srtot=srtot+o;
}
//resultat
printf("\nRtot= %.2f Ohm\n",srtot);
gotoxy(x-19,y+20);
printf("Tryk P† Enter For At Komme Tilbage Til Hoved Menuen");
break;
case 'q':
goto end;
}
getch();
goto start; //g† til start
end: // slut/exit
}
ps I må sige til hvis hundrede point ikke er nok!!!
