Προς το περιεχόμενο

Προτεινόμενες αναρτήσεις

Δημοσ.

καλησπερα ποιοσ θελει να του στειλω ενα κοδικα σε c και να μου το διορθώσει ... εχω κολλησει απειρα :/ και δεν ξερω τι να κανε  :(  :( χελππππππππ 

Δημοσ.
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
 
int dyskolia,aem,max,min;
float ar1, ar2, pls1, pls2, pls3, pls4, plla1, plla2, plla3, plla4,ap,pr;
void tyxaioi(int min, int max);
void praxh(float ar1, float ar2);
void paixnidi(float pr, float ar1, float ar2);
void elenxos_pro(float ar1, float ar2, float ap);
void elenxos_af(float ar1, float ar2, float ap);
void elenxos_poll(float ar1, float ar2, float ap);
void elenxos_die(float ar1, float ar2, float ap);
void epidosh_pro(float pls1, float plla1);
void epidosh_af(float pls2, float plla2);
void epidosh_poll(float pls3, float plla3);
void epidosh_die(float pls4, float plla4);
 
int _tmain(int argc, _TCHAR* argv[])
{
printf("dwse AEM\n");
scanf_s("%d", &aem);
printf("dwse batho dyskolias\n");
scanf_s("%d", &dyskolia);
srand(aem);
if (dyskolia == 1)
{ min = 1; 
max = 9;
tyxaioi(min, max); }
else if (dyskolia == 2)
{
min = 10;
max = 99;
tyxaioi(min,max);
}
else if (dyskolia == 3){
min = 100; 
max = 999;
tyxaioi(min,max); }
else if (dyskolia == 4) {
min = 1000;
max = 9999;
tyxaioi(min,max);
}
else
{
min = 10000;
max = 99999;
tyxaioi(min,max);
}
 
 
return 0;
}
 
void tyxaioi(int a, int d);
{
float ar1,ar2,i;
 for (i = 1 i <= 10 i++){
ar1 = ar % d + a;
ar2 = ar % d + a;
praxh(ar1, ar2);
}
 
void praxh(float ar1, float ar2)
{
float pr;
pr=pr%4+1;
paixnidi(ar1, ar2, pr);
}
void paixnidi(float pr, float ar1, float ar2)
{
float ap;
if (pr == 1){
printf("dwse to apotelesma tis para katw praxeis/n");
printf("\n %f + %f", ar1, ar2);
scanf_s("%f", &ap);
elenxos_pro(ar1,ar2,ap);}
else if (pr == 2){
printf("dwse to apotelesma tis para katw praxeis/n");
printf("\n %f - %f", ar1, ar2);
scanf_s("%f", &ap);
elenxos_af(ar1, ar2,ap);
}
else if (pr == 3){
printf("dwse to apotelesma tis para katw praxeis/n");
printf("\n %f * %f", ar1, ar2);
scanf_s("%f", &ap);
elenxos_poll(ar1, ar2,ap);
}
else if (pr == 4){
printf("dwse to apotelesma tis para katw praxeis/n");
printf("\n %f / %f", ar1, ar2);
scanf_s("%f", &ap);
elenxos_die(ar1, ar2,ap);
}
}
void elenxos_pro(float ar1, float ar2,float ap)
{
float c, pls1, plla1;
c = ar1 + ar2;
pls1 = 0;
plla1 = 0;
if (c = ap) {
printf("mprabo ekanes swsta thn praxh");
pls1 = pls1 + 1;
}
else 
printf("ekabes lathos, prosexe thn epomenh fora to swsto apotelesma einai %d", c);
plla1 = plla1 + 1;
}
}
void elenxos_af(float ar1,float ar2,float ap)
{
float c, pls2, plla2;
c = ar1 - ar2;
pls2 = 0;
plla2 = 0;
if (c = ap) {
printf("mprabo ekanes swsta thn praxh");
pls2 = pls2 + 1;
}
else{
printf("ekabes lathos, prosexe thn epomenh fora to swsto apotelesma einai %f", c);
plla2 = plla2 + 1;
}
}
void elenxos_poll(float ar1,float ar2, float ap)
{
float c, pls3, plla3;
c = ar1 * ar2;
pls3 = 0;
plla3 = 0;
if (c = ap) {
printf("mprabo ekanes swsta thn praxh");
pls3 = pls3 + 1;
}
else{
printf("ekabes lathos, prosexe thn epomenh fora to swsto apotelesma einai %f", c);
plla3 = plla3 + 1;
}
}
void elenxos_die(float ar1,float ar2,float ap)
{
float  c, pls4, plla4;
c=ar1/ar2;
pls4 = 0;
plla4 = 0;
if (c = ap) {
printf("mprabo ekanes swsta thn praxh");
pls4 = pls4 + 1;
}
else{
printf("ekabes lathos, prosexe thn epomenh fora to swsto apotelesma einai %f", c);
plla4 = plla4 + 1;
}
}
void epidosh_pro(float pls1, float plla1) {
float pl_pro, ep;
pl_pro = pls1 + plla1;
ep = (pl_pro-pls1)/pl_pro * 100;
printf("h epidosh sou sthn prosthesh htan %f  \n",ep);
if (ep <= 50){
printf_s("\n posexe den ta phges kala sthn prosthese");
}
else if (ep >= 50 && ep < 100){
printf("\n mprabo ta phges kala sthn prosthesh");
}
else{
printf("\n synxaritiriaa!!! ta phges arista");
}
}
 
void epidosh_af(float pls2,float plla2) 
{
float pl_af, ep;
  pl_af = pls2 + plla2;
ep=(pl_af-pls2)/pl_af * 100;
 
printf("h epidosh sou sthn aferesh htan %f \n", ep);
if (ep <= 50){
printf_s("\n posexe den ta phges kala sthn aferesh");
}
else if (ep >= 50 && ep < 100){
printf("\n mprabo ta phges kala sthn aferesh");
}
else{
printf("\n synxaritiriaa!!! ta phges arista");
}
}
void epidosh_poll(int pls3,int plla3);
{
float pl_pll, ep;
pl_pll = pls3 + plla3;
ep = (pl_pll - pls3) / pl_pll) * 100;
 
printf("h epidosh sou ston pollaplasiasmo htan %f  \n", ep);
if (ep <= 50){
printf_s("\n posexe den ta phges kala ston pollaplasiasmo");
else if (ep >= 50 && ep < 100)
printf("\n mprabo ta phges kala ston pollaplaiasmo");
else
printf("\n synxaritiriaa!!! ta phges arista");
}
}
void epidosh_die(float pls4,float plla4); 
{
float ep,pl_die;
pl_die = pls4 + plla4;
ep = (pl_die - pls4) / pl_die) * 100;
 
printf("h epidosh sou sthn dieresh htan %f  \n", ep);
if (ep <= 50){
printf_s("\n posexe den ta phges kala sthn dieresh");
else if (ep >= 50 && ep < 100)
printf("\n mprabo ta phges kala sthn dieresh");
else
printf("\n synxaritiriaa!!! ta phges arista");
}
}

ειναι σαν παιχνιδι εμφανιζει 10 πραξεισ με τυχαιουσ αριθμου κ ζητα απο τον χρηστη να βρει το αποτελεσμα και μετα εμφανιζει πως τα πηγε

Δημοσ.

Κανένας δεν πρόκειται να σε βοηθήσει αν δεν βάλεις τον κώδικα σε tabs ,αν δεν πεις που έχεις κολλήσει  και αν δεν βάλεις περισσότερα σχόλια ώστε να καταλάβουμε τι κάνεις.

  • Like 6
Δημοσ.

Τι να πρωτοσχολιάσει κανείς εδώ πέρα....

(και με μια ματία που μπορεσα να ρίξω, δεν πρέπει να κάνει ούτε compile αυτό...)


Ο κώδικάς σου έχει πολλά πολλά προβλήματα!

Θα σχολιάσω ό,τι μπόρεσα να βγάλω άκρη...

  1. Δώσε στις μεταβλητές σου πιο περιγραφικά ονόματα.
  2. Χρησιμοποιείς πολλές global μεταβλητές. Και ειδικά με τα ονόματα που έχεις δώσει και έτσι που έχεις δώσει τον κώδικα χωρίς στοίχιση είναι σχεδόν αδύνατον κάποιος να παρακολουθήσει τι γίνεται στο πρόγραμμα.
  3. Το να καλείς τη μία συνάρτηση μέσα από την άλλη είναι πολύ άσχημο προγραμματιστικό στυλ και δεν σε βοηθάει ούτε στην υλοποίηση ούτε στην απασφαλμάτωση του προγράμματός σου.
  4. Σε άλλο thread ρώτησες για την rand(). Δεν βλέπω να έχεις χρησιμοποιήσει κάπου αυτά που σου έιπαν τα παιδιά, εκτός από την srand().
  5. Δοκίμασες να φτιάξεις κομμάτι κομμάτι το πρόγραμμα σου και να το κάνεις compile σταδιακά για να δεις τι δουλευει και τι όχι, κι αν δουλεύει αν κάνει αυτό που θέλεις; Με μία γρήγορη ματιά βλέπω ότι ο compiler θα έπρεπε να σου χτηπήσει τουλάχιστον σε 5-6 σημεία...

Φαντάζομαι είναι κι άλλα, όμως έτσι όπως εδωσες τον κώδικα, δεν μπορώ να τον κοιτάξω παραπάνω...

Δημοσ. (επεξεργασμένο)

Παρατήρησα πως όσα ορίσματα δηλώνεις για κάθε συνάρτηση, τα δηλώνεις και σαν global μεταβλητές.

Δε χρειάζεται αυτό.

 

Επίσης όπως είπε και ο προλαλήντας, δεν είναι καλή πρακτική να καλείς συνάρτηση μέσα από συνάρτηση, εκτός

κι αν είναι αναδρομική. Τουλάχιστον σε αυτά τα απλά προβλήματα είναι πλήρως αχρείαστο αυτό που κάνεις.

Θα μπορούσες κάλλιστα αντί να έχει πχ μία void συνάρτηση, η οποία καλεί κάποια άλλη void, να ορίσεις μία

επιστρεφόμενη τιμή και στη συηνέχεια να την περάσεις στην επόμενη συνάρτηση. Παράδειγμα:

int main(int argc, **argv)
{
        int i;
        float ret1, ret2, res;
        ....
        for (i = 1; i <= 10; ++i) {
                ret1 = my_fun(min, max);
                ret2 = my_fun(min, max);
                res = praxh(ret1, ret2);
                ...
        }
        
        return(0);
}

int my_fun(a, d)
{
        float sthg;

        sthg = some_operations;

        return(sthg);
}

Φτιάξε το main loop σου στην main και από εκεί κάλεσε τα πάντα με βάση αυτή τη λογική.

 

Άλλες παρατηρήσεις είναι ότι ακόμη δεν έχεις μάθει καλά τη χρήση των δομών επανάληψης for: ξεχνάς να βάλεις τα ;

 

Επίσης, είδα ότι σε κάποιες συναρτήσεις έχεις την ανάγκη να επιστρέψεις 2 τιμές. Μάλλον αυτό σε μπέρδεψε. Αν δεν έχεις

μάθει ακόμη για τους pointers, ή για static arrays, τότε καλό είναι να δουλεύεις όπως στο παράδειγμα που σου έγραψα.

Κάλεσε μία συνάρτηση και 2 φορές. Δεν πειράζει.

 

Τέλος, το σημαντικότερο όλων είναι να κάνεις το πρόγραμμά σου compile κάθε φορά που γράφεις κάποια καινούρια

λειτουργικότητα και να το δοκιμάζεις αμέσως. Έτσι θα βεβαιώνεσαι ότι πατάς κάπου σταθερά για να προχωρήσεις

στην ανάπτυξη.

 

Υ.Γ.: Πρόσεχε τους τίτλους που βάζεις στα post. Με τέτοιους τίτλους πολλοί δεν κάνουν καν τον κόπο να ανοίξουν το

post σου.

Επεξ/σία από gon1332
Δημοσ.

Τι συναντάει κανείς σε ένα φορουμ :P τελικά είμαστε μικρή οικογένεια αγαπητά μου :P .

 

@topic starter, αν θες δώσε εκφώνηση.

Δημοσ. (επεξεργασμένο)

@ts: Το παράξενο θα ήταν να μην κόλλαγες, μιας και φαίνεται να έχεις πολύ βασικές ελλείψεις. Ένα πολύ καλό βιβλίο για να μάθεις C είναι αυτό εδώ.

 

Τα πρώτα που πρέπει να μάθεις και να καθιερώσεις κατά την γνώμη μου, ανεξαρτήτως γλώσσας, είναι να γράφεις στοιχισμένο, καθαρό κώδικα με σχόλια και διστήματα, να χρησιμοποιείς εύστοχες ονομασίες μεταβλητών, συναρτήσεων, κλπ και να ορίζεις τις μεταβλητές σου σε όσο το δυνατόν στενότερο scope (τα άκρως αντίθετα δηλαδή από όσα περιέχει ο κώδικας που ποστάρισες :P).

 

Κατά τα άλλα, μου κίνησε το ενδιαφέρον το θέμα που πραγματεύεται ο κώδικας που πόσταρες και μιας και έχω νοσταλγήσει την καθαρή C (εννοώ σε αντίθεση με τη χρήση APIs που είναι ο κανόνας) έκατσα να βγάλω άκρη.

 

Νομίζω κάτι κατάλαβα, αλλά το ξανά έγραψα όλο από την αρχή (μόνο κάτι ελάχιστες ονομασίες κράτησα ίδιες με τον κώδικά σου). Αντί όμως για ατέλειωτα switch, if-then-else, συναρτήσεις, κλπ χρησιμοποίησα ένα array από structs που μεταξύ άλλων περιέχει και function pointers για τις πράξεις.

 

Οπότε, αφού το κανα που το κάνα ως διάλειμμα, το ποστάρω κι εδώ σε spoiler για να πάρεις γεύση και ίσως σε βοηθήσει κιόλας (ή όποιον άλλον). Περιέχει και 3-4 συναρτήσεις και macros γενικής χρήσης, που μπορούν δηλαδή να χρησιμοποιηθούν ατόφια και σε άλλα projects.

 

Κώδικας

 

 

/***********************************************
 * A little game to test your floating arithmetic skills.
 *
 * A game last 10 rounds. On each round a high-school arithmetic
 * operation along with 2 operands are picked at random. The range
 * from which the operands are picked depends on the selected level
 * of difficulty (they vary from 1 top 5). The greater the difficulty
 * level, the wider the range. It starts from [1.0, 9.0] at level 1
 * and goes up to [10000.0, 99999.0] at level 5.
 *
 * At the beginning of a game, besides the level of difficulty, you
 * are also asked to input a seed for the pseudo-random generator.
 * Same seeds generate same sequences of operands and operations, so
 * you can replay any game by providing the same seed when starting it.
 * 
 * On each round you are asked for the result of the picked operation,
 * and your answer is graded internally:
 *	+10 points for every correct
 *	-10 points for each wrong answer
 *
 * Before the game ends, your performance along with related statistics
 * are displayed on the screen.
 *
 * NOTE:
 * To compile the source code, the compiler must comply to the ANSI C99 standard.
 ***********************************************
 */

/* -----------------------
 * Header File Inclusions
 * -----------------------
 */
#include <stdio.h>
#include <stdlib.h>		// for srand(), rand()
#include <stdbool.h>		// for bool, true, false (needs C99 or better)
#include <stdarg.h>		// for vsscanf()
#include <math.h>		// for fabsf()
#include <float.h>		// for FLT_MAX

/* ----------------------------------
 * Macros & Global Constants
 * ----------------------------------
 */

// max size of chars for an operation label ("Addition", "Subtraction", etc).
#define MAX_OPLABEL_SIZE	(30+1)

// floats should never be compared for equality with the default = operator
#define FLOAT_DELTA		0.000000001
#define FLOAT_EQUAL(f1, f2)	( fabsf((f1)-(f2)) <= FLOAT_DELTA )

// cross-platform alternative to system("pause")
#define pressENTER()					\
do {							\
	int c;						\
	printf( "Press ENTER..." ); fflush( stdout );	\
	while ( EOF != (c=getchar()) && '\n' != c );	\
} while(0)

// print custom message (if any) along with debug info in the stderr (needs C99)
#define DBG_PRINTF( ... )						\
do {									\
	fprintf( stderr, "*** %s|%s:%d\n", __FILE__, __func__, __LINE__ );\
	fprintf( stderr, __VA_ARGS__ );					\
	fflush(stderr);							\
	fputc('\n', stderr);						\
} while(0)

/* ----------------------------------
 * Custom Types
 * ----------------------------------
 */

// Operation IDs for the arithmetic operations we support
enum OpID
{
	OP_NONE = -1,				// ensure int enumerations
	OP_ADD  = 0,
	OP_SUB,
	OP_MUL,
	OP_DIV,

	MAX_OPERATIONS
};

// Describes an arithmetic operation.
typedef struct Operation
{
	char label[MAX_OPLABEL_SIZE];		// "Addition", "Subtraction", etc
	char  symbol;				// '+', '-', etc
	float (*pfunc)(float, float);		// ptr to the func that implements the operation
	int   score;				// player's score for this operation
	int   count;				// # of times this operation occurred
}Operation;

// Describes a range for generating a pseudo-random float.
typedef struct RandRange
{
	float min;
	float max;
}RandRange;

/* ----------------------------------
 * Function Forward Decelerations
 * ----------------------------------
 */
// No need, the functions are defined in their proper order.

/* ----------------------------------
 * Function Definitions
 * ----------------------------------
 */

/*******************************************//**
 * A variant of libc's scanf() for handling a
 * bit better the stdin line-buffering problems.
 ***********************************************
 */
static bool myscanf( int nargs, const char *format, ... )
{
	enum { MAXINPUT = (255+1) };		// max size of line when reading stdin
	char      input[MAXINPUT] = {'\0'};	// buffer for reading a line form stdin
	int       n = EOF;
	va_list   ap;

	// sanity check
	if ( !format ) {
		DBG_PRINTF( "invalid argument (NULL pointer)" );
		return false;
	}
	if ( nargs < 1 ) {
		DBG_PRINTF( "invalid argument value" );
		return false;
	}

	va_start(ap, format);
	do {
		fgets( input, MAXINPUT, stdin );
		n = vsscanf(input, format, ap);
	} while ( nargs != n );

	va_end( ap );

	return true;
}


/*******************************************//**
 * Returns a pseudo-random float in the range [0, floor(max)].
 * The integral part of max is used as the inclusive upper-limit.
 ***********************************************
 */
static inline float random_float( float max )
{
	return (float)rand() / ( (float)RAND_MAX / floorf(max) );
}

/*******************************************//**
 * Returns a pseudo-random float in the range [min, max].
 * Both min and max are inclusive limits.
 ***********************************************
 */
static float random_float_in_range( float min, float max )
{
	return min + random_float( fabsf(max - min) );
}

/*******************************************//**
 * Given a level of difficulty, it calculates and
 * stores the boundaries of a range, from which the
 * operands of an operation can be picked randomly
 * later on.
 *
 * The lower bound of the range varies from 10000.f to 1.f,
 * while the upper bound varies from 99999.f to 9.f.
 * Both are stepped by consecutive powers of 10. 
 * 
 * If the local constant MAX_LEVEL is changed, then the
 * initial value assignments to the range boundaries should
 * also be adjusted to accommodate to the new MAX_LEVEL.
 ***********************************************
 */
static void randRange_from_level( RandRange *rr, unsigned int level )
{
	const unsigned int MAX_LEVEL = 5;

	// sanity check
	if ( !rr ) {
		DBG_PRINTF( "invalid argument (NULL pointer)" );
		return;
	}

	// values for maximum level
	rr->min = 10000.f;
	rr->max = 99999.f;

	// values for smaller levels (level 0 counts as MAX_LEVEL)
	if ( level > 0 && level < MAX_LEVEL )
	{
		float divisor = powf( 10.f, (MAX_LEVEL - level) );
		rr->min = floorf( rr->min / divisor );
		rr->max = floorf( rr->max / divisor );
	}
}

/*******************************************//**
 * Prints statistics about the player's performance.
 *
 * The function uses the information stored inside
 * each element of the operations[] array at every
 * round, and calculates the average grade for each
 * operation.
 *
 * It also grades verbally the player's performance,
 * according to his average grade:
 * 	less than maxGrade/2          is bad,
 * 	[maxGrade/2, 0.75 * maxGrade) is good,
 * 	[0.75 * maxGrade, maxGrade)   is very good,
 *      maxGrade                      is excellent.
 *
 * The rounds argument should be the total number
 * of rounds in a complete game (but it can also
 * be used for any non-negative number of rounds,
 * as long as they do not exceed the total # of
 * rounds).
 ***********************************************
 */
static void print_stats( Operation operations[], int rounds, int maxGrade )
{
	// sanity check
	if ( !operations ) {
		DBG_PRINTF( "invalid argument (NULL pointer)" );
		return;
	}
	if ( rounds < 1 ) {
		DBG_PRINTF( "invalid argument value" );
		return;
	}

	puts( "\nEPIDOSEIS" );
	puts( "---------" );

	for (int i=0; i < MAX_OPERATIONS; i++)
	{
		// display score & statictics
		int score = operations[i].score;
		int count = operations[i].count;
		printf( "%s (%d)\t: %d\t", operations[i].label, count, score );

		if ( 0 == count ) {
			putchar( '\n' );
			continue;
		}

		// calc average grade & evaluate verbally the player
		int grade = score / count;
		const int QUART = maxGrade / 4;
		if ( grade < 2 * QUART ) {
			puts( "Den ta phges katholoy kala" );
		}
		else if ( grade < 3 * QUART ) {
			puts( "Ta phges arketa kala" );
		}
		else if ( grade < maxGrade ) {
			puts( "Mprabo, ta phges poly kala" );
		}
		else {
			puts( "SYGXARHTHRIA, TA PHGES ARISTA!" );
		}
	}
	putchar( '\n' );
}

/*******************************************//**
 * These functions implement the arithmetic operations
 * we support in our little game. On error, they return
 * FLT_MAX.
 *
 * The only error that is handled is "division by 0".
 * For production, a check for float overflowing MUST
 * also be implemented (at the very least).
 *
 * These functions are not used directly. They are
 * called via function pointers which are stored
 * inside the operations[] array (see the main()
 * function for the initialization of that array).
 ***********************************************
 */
static float add_floats( float x, float y )
{
	return x + y;
}
static float subtract_floats( float x, float y )
{
	return x - y;
}
static float multiply_floats( float x, float y )
{
	return x * y;
}
static float divide_floats( float x, float y )
{
	if ( 0 == y ) {
		DBG_PRINTF( "Division by 0 prevented, %g returned instead", FLT_MAX );
		return FLT_MAX;
	}
	return x / y;
}

/*******************************************//**
 * Application's entry point.
 ***********************************************
 */
int main( void )
{
	const int    NROUNDS    = 10;
	const int    ARISTA     = 10;
	unsigned int aem        = 0;		// user-defined seed for the pseudo-random generator
	RandRange    randRange = {0.f, 0.f};	// range for generating pseudo-random floats
	int          dyskolia = 0;		// level of difficulty

	// array of operations (must be in synch with both: struct Operation AND enum OpID)
	Operation operations[ MAX_OPERATIONS ] = {
	/*        .label        .symbol  .pfunc          .score   .count*/
		{ "Prosthesh",    '+',   add_floats,        0,       0 },
		{ "Afairesh ",    '-',   subtract_floats,   0,       0 },
		{ "Pol/smos ",    '*',   multiply_floats,   0,       0 },
		{ "Diairesh ",    '/',   divide_floats,     0,       0 }
	};

	printf( "Dwse AEM: "  );
	myscanf( 1, "%u", &aem );

	srand( aem );

	printf( "Dwse bathmo dyskolias: " );
	myscanf( 1, "%d", &dyskolia );

	randRange_from_level( &randRange, dyskolia );

	for (int i=0; i < NROUNDS; i++)
	{
		// pick random operation, random operands & calculate the result 
		enum OpID id = rand() % MAX_OPERATIONS;
		float ar1    = random_float_in_range( randRange.min, randRange.max );
		float ar2    = random_float_in_range( randRange.min, randRange.max );
		float result = operations[id].pfunc(ar1, ar2);

		operations[id].count++;

		// ask user for his result
		float apotelesma = FLT_MAX;
		printf(
			"\nGYROS #%d\n"
			"Poso kanei %15.9f %c %-15.9f;\n",
			i+1, ar1, operations[id].symbol, ar2
		);
		myscanf( 1, "%f", &apotelesma );

		// inform user about his answer and update score
		if ( !FLOAT_EQUAL(apotelesma, result) )
		{
			printf( "Lathos, to swsto apotelesma einai: %-15.9f\n\n", result );
			operations[id].score -= ARISTA;
		}
		else
		{
			puts( "Mprabo, ekanes swsta thn praxh!\n" );
			operations[id].score += ARISTA;
		}

		pressENTER();

	}

	print_stats( operations, NROUNDS, ARISTA );
	pressENTER();

	return 0;
}

 

Επεξ/σία από migf1
  • Like 11
Δημοσ.

@migf1 ευγε για τη μορφή που εχει γραφεί ο κώδικας (σχόλια, δομή, εξηγήσεις, κλπ)

Χαίρεσαι να το διαβάζεις! 

Δημοσ.

Ενταξει εχω κανει μερικα λαθακια... δεν γίνονται ολοι μαστερ σε κατι που πρωτο ξεκηναν με την μια, κανω C εδω και τρις μήνες ..

  • Moderators
Δημοσ.

Ενταξει εχω κανει μερικα λαθακια... δεν γίνονται ολοι μαστερ σε κατι που πρωτο ξεκηναν με την μια, κανω C εδω και τρις μήνες ..

 

Γι' αυτό και οι καλοί κύριοι bird, gon1332 και migf1 σου έδωσαν πληθώρα συμβουλών με το τι μπορείς να βελτιώσεις...

  • Like 2
Δημοσ.

Ενταξει εχω κανει μερικα λαθακια... δεν γίνονται ολοι μαστερ σε κατι που πρωτο ξεκηναν με την μια, κανω C εδω και τρις μήνες ..

 

Εκτίμησε τουλάχιστον τον κόπο αυτών που σου απάντησαν και δώσε προσοχή, ειδικά σε αυτά που σου είπε ο migf1 γιατί είναι πολύ σημαντικά.

 

Φιλικά πάντα :)

Δημοσ.

Ενταξει εχω κανει μερικα λαθακια... δεν γίνονται ολοι μαστερ σε κατι που πρωτο ξεκηναν με την μια, κανω C εδω και τρις μήνες ..

Όπως κι εγώ έτσι πιστεύω και οι φίλοι bird και gon1332 δεν ανταποκριθήκαμε στο κάλεσμά σου για βοήθεια για να σε προσβάλουμε, αλλά για να σε βοηθήσουμε να βελτιωθείς. Ο κώδικας που παρέθεσες δεν έχει "μερικά λαθάκια". Έχει πολλά και στοιχειώδη λάθη, τόσο σε επίπεδο σύνταξης & χρήσης της γλώσσας (όπως π.χ. το ότι η C δεν υποστηρίζει nested functions), όσο και σε επίπεδο coding style.

 

Αν πρόκειται για εργασία σε σχολή και το μόνο που σε ενδιαφέρει είναι να περάσεις το μάθημα χωρίς να κοπιάσεις, τότε υποθέτω μπορείς να αγνοήσεις τις επισημάνσεις που σου κάναμε. Αν από την άλλη μεριά σε ενδιαφέρει να ασχοληθείς σοβαρά με τον προγραμματισμό, τότε δεν νομίζω πως θα τα καταφέρεις αν θεωρείς πως έχει μόνο "μερικά λαθάκια" ο κώδικας που παρέθεσες.

 

Όπως και να 'χει, καλή συνέχεια.

 

ΥΓ. Ευχαριστώ κι εγώ με τη σειρά μου παιδιά για τα καλά σας λόγια.

  • Like 1

Δημιουργήστε ένα λογαριασμό ή συνδεθείτε για να σχολιάσετε

Πρέπει να είστε μέλος για να αφήσετε σχόλιο

Δημιουργία λογαριασμού

Εγγραφείτε με νέο λογαριασμό στην κοινότητα μας. Είναι πανεύκολο!

Δημιουργία νέου λογαριασμού

Σύνδεση

Έχετε ήδη λογαριασμό; Συνδεθείτε εδώ.

Συνδεθείτε τώρα
  • Δημιουργία νέου...