jordaninio Δημοσ. 24 Δεκεμβρίου 2011 Δημοσ. 24 Δεκεμβρίου 2011 εχω μια ασκηση για τη σχολη.αλλα οπως την εχω φτιαξει δεν μπορω να καταλαβω γιατι δν μ δουλευει οταν παω στο release.. #include<stdio.h> int prosthesi(int x,int y,int z); int main() { int arithmo1; int arithmo2; int res; char praxi; printf ( "Parakalo pliktrologiste: +. gia prosthesi , -. gia afairesi , *. gia pollaplasiasmo , /. gia diairesi , ^. gia ton ipologismo tis dinamis , e. gia exodo apo to programma\n" ); scanf( "%d",&praxi); printf ("dose arithmo1\n"); scanf ("%d",&arithmo1); printf ("dose arithmo2\n"); scanf ("%d",&arithmo2); while (praxi != 'e' ) { if (praxi = '+' ) printf ("d%", prosthesi(arithmo1,arithmo2,res) ); return 0; } #include<stdio.h> { int prosthesi(int arithmo1,int arithmo2,int res ); res= arithmo1+arithmo2; return res; }
nilosgr Δημοσ. 24 Δεκεμβρίου 2011 Δημοσ. 24 Δεκεμβρίου 2011 Το #include<stdio.h> δεν χρειαζεται δυο φορες. >/*η τιμη του δεν γινετεαι res να αλλαξει, οταν θα πατε στους δεικτες θα μαθεις το "γιατι"*/ int prosthesi(int arithmo1,int arithmo2,int res ) { /* res= arithmo1+arithmo2; return res; καλυτερα ετσι */ return arithmo1+arithmo2; } Επισης οταν θελουμε εναν χαρακτηρα απο το χρηστη (οπως εσυ τον char praxi) αντι για scanf() καλουμε getc(), δηλαδη: >praxi = getc();
mtsouk Δημοσ. 24 Δεκεμβρίου 2011 Δημοσ. 24 Δεκεμβρίου 2011 Επίσης, η σύγκριση γίνεται με δύο = και όχι με ένα: // if (praxi = '+' ) φιλικά,
nilosgr Δημοσ. 24 Δεκεμβρίου 2011 Δημοσ. 24 Δεκεμβρίου 2011 Επίσης, η σύγκριση γίνεται με δύο = και όχι με ένα: // if (praxi = '+' ) φιλικά, ναι, μου διεφυγε, δεν εκανα compile Το σωστο ειναι: >if (praxi == '+')
jordaninio Δημοσ. 24 Δεκεμβρίου 2011 Μέλος Δημοσ. 24 Δεκεμβρίου 2011 καταρχην ευχαριστω για την γρηγορη απαντηση.. λοιπον το εχω γραψει τωρα ετσι #include<stdio.h> int prosthesi(int x,int y,int z); int main() { int arithmo1; int arithmo2; int res; char praxi; printf ( "Parakalo pliktrologiste: +. gia prosthesi , -. gia afairesi , *. gia pollaplasiasmo , /. gia diairesi , ^. gia ton ipologismo tis dinamis , e. gia exodo apo to programma\n" ); scanf( "%d",&praxi); printf ("dose arithmo1\n"); scanf ("%d",&arithmo1); printf ("dose arithmo2\n"); scanf ("%d",&arithmo2); while (praxi != 'e' ) { if (praxi == '+' ) printf ("d%", prosthesi(arithmo1,arithmo2,res) ); return 0; } { int prosthesi(int arithmo1,int arithmo2,int res ); return arithmo1+arithmo2 ; } και συνεχιζει να μου βγαζει λαθη:1>------ Build started: Project: arithmomixanh, Configuration: Release Win32 ------ 1>machine.obj : error LNK2001: unresolved external symbol "int __cdecl prosthesi(int,int,int)" (?prosthesi@@YAHHHH@Z) 1>C:\Users\Ιορδάνης\documents\visual studio 2010\Projects\arithmomixanh\Release\arithmomixanh.exe : fatal error LNK1120: 1 unresolved externals ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
nilosgr Δημοσ. 24 Δεκεμβρίου 2011 Δημοσ. 24 Δεκεμβρίου 2011 Λοιπον, το res το βγαζουμε εντελως απο την κεφαλιδα της συναρτησης prosthesi(). Οποτε γινετε ετσι: >int prosthesi(int arithmo1,int arithmo2) { return arithmo1+arithmo2; } >/* Και αντι για scanf( "%d",&praxi) βαζεις: */ praxi = getc();
Leuteris Δημοσ. 24 Δεκεμβρίου 2011 Δημοσ. 24 Δεκεμβρίου 2011 καταρχην ευχαριστω για την γρηγορη απαντηση.. λοιπον το εχω γραψει τωρα ετσι #include<stdio.h> int prosthesi(int x,int y,int z); int main() { int arithmo1; int arithmo2; int res; char praxi; printf ( "Parakalo pliktrologiste: +. gia prosthesi , -. gia afairesi , *. gia pollaplasiasmo , /. gia diairesi , ^. gia ton ipologismo tis dinamis , e. gia exodo apo to programma\n" ); scanf( "%d",&praxi); printf ("dose arithmo1\n"); scanf ("%d",&arithmo1); printf ("dose arithmo2\n"); scanf ("%d",&arithmo2); while (praxi != 'e' ) { if (praxi == '+' ) printf ("d%", prosthesi(arithmo1,arithmo2,res) ); return 0; } { int prosthesi(int arithmo1,int arithmo2,int res ); return arithmo1+arithmo2 ; } και συνεχιζει να μου βγαζει λαθη:1>------ Build started: Project: arithmomixanh, Configuration: Release Win32 ------ 1>machine.obj : error LNK2001: unresolved external symbol "int __cdecl prosthesi(int,int,int)" (?prosthesi@@YAHHHH@Z) 1>C:\Users\Ιορδάνης\documents\visual studio 2010\Projects\arithmomixanh\Release\arithmomixanh.exe : fatal error LNK1120: 1 unresolved externals ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== Το πρόγραμμα σου έχει πολλά συντακτικά αλλα και λογικά λαθη πχ το while σου δεν θα τελειώσει ποτέ αφου η μεταβλητή praxi δεν αλλάζει τιμή!Προσπάθησε να διορθόσεις τα συντακτικά λαθη.. Δες και αυτό: >#include<stdio.h> float prosthesi(float arithmo1,float arithmo2); int main() { float arithmo1,arithmo2; char praxi; do{ fflush(stdin); printf( "Parakalo pliktrologiste:\n +. gia prosthesi\n-. gia afairesi\n*. gia pollaplasiasmo\n/. gia diairesi\n^. gia ton ipologismo tis dinamis\ne. gia exodo apo to programma\n" ); praxi=getchar(); }while(praxi!='+' && praxi!='-'&& praxi!='*'&& praxi!='/'&& praxi!='e'&& praxi!='^'); while(praxi!='e') { printf ("dose arithmo1\n"); scanf ("%f",&arithmo1); printf ("dose arithmo2\n"); scanf ("%f",&arithmo2); switch(praxi) { case'+': printf("%.2f\n",prosthesi(arithmo1,arithmo2)); break; } do{ fflush(stdin); printf( "Parakalo pliktrologiste:\n +. gia prosthesi\n-. gia afairesi\n*. gia pollaplasiasmo\n/. gia diairesi\n^. gia ton ipologismo tis dinamis\ne. gia exodo apo to programma\n" ); praxi=getchar(); }while(praxi!='+' && praxi!='-'&& praxi!='*'&& praxi!='/'&& praxi!='e'&& praxi!='^'); } return 0; } float prosthesi(float arithmo1,float arithmo2) { return arithmo1+arithmo2; }
jordaninio Δημοσ. 25 Δεκεμβρίου 2011 Μέλος Δημοσ. 25 Δεκεμβρίου 2011 λοιπον επειδη δεν ημουν συγκεκριμενος.η ασκηση λεει να διαβαζει δυο αριθμους και την πραξη που θελω και να καλειται η αντιστοιχη συναρτηση.το προγραμμα σταματαει οταν δοθει ως πραξη το e. την τελειωσα αλλα παλι μου βγαζει λαθη.. #include<stdio.h> int main() { int arithmo1; int arithmo2; char praxi; printf ( "Parakalo pliktrologiste: +. gia prosthesi , -. gia afairesi , *. gia pollaplasiasmo , /. gia diairesi , ^. gia ton ipologismo tis dinamis , e. gia exodo apo to programma\n" ); praxi = getc(); printf ("dose arithmo1\n"); scanf ("%d",&arithmo1); printf ("dose arithmo2\n"); scanf ("%d",&arithmo2); while (praxi != 'e' ) { if (praxi == '+' ) printf ("d%", prosthesi(arithmo1,arithmo2) ); else if (praxi=='-') printf("d%",afairesi(arithmo1,arithmo2) ); else if(praxi=='*') printf("d%",pollaplasiasmos(arithmo1,arithmo2)); else if(praxi=='/' && airthmo2!=0); printf("d%".diairesi(arithmo1,arithmo2); else if(praxi=='^'); printf("d%",dinami(arithmo1,arithmo2); printf ( "Parakalo pliktrologiste: +. gia prosthesi , -. gia afairesi , *. gia pollaplasiasmo , /. gia diairesi , ^. gia ton ipologismo tis dinamis , e. gia exodo apo to programma\n" ); praxi = getc(); } return 0; } { int prosthesi(int arithmo1,int arithmo2 ); return arithmo1+arithmo2 ; } { int afairesi(int arithmo1,arithmo2); return arithmo1-arithmo2 } { int pollaplasiasmos(int arithmo1,arithmo2); return arithmo1*arithmo2 } { int diairesi(int arithmo1,int arithmo2); return arithmo1/arithmo2 } { int dinami(int arithmo1,int arithmo2); return airthmo1^arithmo2 }
Leuteris Δημοσ. 25 Δεκεμβρίου 2011 Δημοσ. 25 Δεκεμβρίου 2011 Συγνώμη βιβλίο δεν έχεις; αν είχες θα έβλεπες πολύ εύκολα οτι οι πρόσθιες δηλώσης των συναρτήσεων είναι κάπως έτσι >int prosthesi(int arithmo1,int arithmo2); και στην συνέχεια > int prosthesi(int arithmo1,int arithmo2) { return arithmo1+arithmo2 ; } αντί για praxi = getc(); βάλε praxi=getch(); ή praxi=getchar(); ή praxi=fgetc(stdin); επίσεις το αλφαριθμητικό μορφοποίησεις είναι %d και όχι d%.Πρόσεξε τις printf και τις παρενθέσεις. Τέλος η δύναμη δεν υπολογίζεται με τον τελεστή ^,υπολόγισε την με μία for. Πάντως ο κώδικα σου φαίνετε πολύ..ψεκάστε σκουπίστε τελειώσατε..
jordaninio Δημοσ. 25 Δεκεμβρίου 2011 Μέλος Δημοσ. 25 Δεκεμβρίου 2011 φιλε μου το ξερω αλλα εχω ξεκινησει c εδω και ενα μηνα και η ασκηση αυτη ειναι η πρωτη μου αποπειρα..το βιβλιο δεν το εχω αυτες τις μερες για αυτο κανω ηλιθια λαθη..μηπως ξερεις τιποτα ονλάιν να δω για να μην σας πριζω? 1>------ Build started: Project: arithmomixanh, Configuration: Release Win32 ------ 1>machine.obj : error LNK2001: unresolved external symbol "int __cdecl prosthesi(int,int,int)" (?prosthesi@@YAHHHH@Z) 1>C:\Users\Ιορδάνης\Documents\Visual Studio 2010\Projects\arithmomixanh\Release\arithmomixanh.exe : fatal error LNK1120: 1 unresolved externals ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== αυτα τα λαθη πως διορθωνω?
Προτεινόμενες αναρτήσεις
Δημιουργήστε ένα λογαριασμό ή συνδεθείτε για να σχολιάσετε
Πρέπει να είστε μέλος για να αφήσετε σχόλιο
Δημιουργία λογαριασμού
Εγγραφείτε με νέο λογαριασμό στην κοινότητα μας. Είναι πανεύκολο!
Δημιουργία νέου λογαριασμούΣύνδεση
Έχετε ήδη λογαριασμό; Συνδεθείτε εδώ.
Συνδεθείτε τώρα