• Downloads
  • ! Read Me !
  • Μαθήματα
  • Φοιτητικά
  • Τεχνικά Θέματα
  • Συζητήσεις
  • Happy Hour!
  • About THMMY.gr
 V  < 
Search:  
Welcome, Guest. Please login or register.
June 18, 2026, 16:37:40 pm

Login with username, password and session length
Links
  Thmmy.gr portal
   Forum
   Downloads
   Ενεργ. Λογαριασμού
   Επικοινωνία
  
  Χρήσιμα links
   Σελίδα τμήματος
   Βιβλιοθήκη Τμήματος
   Elearning
   Φοιτητικά fora
   Πρόγραμμα Λέσχης
   Πρακτική Άσκηση
   Ηλεκτρονική Εξυπηρέτηση Φοιτητών
   Διανομή Συγγραμμάτων
   Ψηφιακό Καταθετήριο Διπλωματικών
   Πληροφορίες Καθηγητών
   Instagram @thmmy.gr
   mTHMMY
  
  Φοιτητικές Ομάδες
   ACM
   Aristurtle
   ART
   ASAT
   BEAM
   BEST Thessaloniki
   EESTEC LC Thessaloniki
   EΜΒ Auth
   IAESTE Thessaloniki
   IEEE φοιτητικό παράρτημα ΑΠΘ
   SpaceDot
   VROOM
   Panther
  
Πίνακας Ελέγχου
Welcome, Guest. Please login or register.
June 18, 2026, 16:37:40 pm

Login with username, password and session length

Αναζήτηση

Google

THMMY.gr Web
Πρόσφατα
[Η/Μ Πεδίο ΙΙ] Γενικές απ...
by Nikos_313
[Today at 14:01:54]

[Ηλεκτρονική ΙΙ] Γενικές ...
by nmpampal
[Today at 07:37:37]

Αποτελέσματα Εξεταστικής ...
by Nikos_313
[June 17, 2026, 10:51:29 am]

[Οργάνωση Υπολογιστών] Γε...
by Lalson
[June 17, 2026, 10:37:39 am]

Κάμερες στην Πρυτανεία το...
by RivenT
[June 16, 2026, 23:48:23 pm]

Πότε θα βγει το μάθημα; -...
by Giannis Masterio
[June 16, 2026, 16:09:27 pm]

[Μικροεπεξεργαστές] Γενικ...
by G.V.
[June 16, 2026, 15:31:13 pm]

[Εφ.Θερμοδυναμική] Γενικέ...
by femanak
[June 16, 2026, 11:11:17 am]

[Διανεμημένη Παραγωγή] Γε...
by astra
[June 15, 2026, 19:20:06 pm]

H Στοά των Off Topic
by χηρουλα Αλεξίου
[June 15, 2026, 17:39:58 pm]

Γιατί οι ΤΗΜΜΥδες έχουν μ...
by Karaμazoβ
[June 15, 2026, 14:31:16 pm]

Των συνειρμών το παίγνιο....
by χηρουλα Αλεξίου
[June 15, 2026, 06:18:44 am]

[ΣΗΕ ΙΙ] Γενικές απορίες ...
by Λαμπτήρας
[June 12, 2026, 13:36:19 pm]

[Ισχύος II] Γενικές απορί...
by Nikos_313
[June 11, 2026, 14:05:57 pm]

[Ημιαγωγά Υλικά] Απορίες ...
by Nikos_313
[June 11, 2026, 10:23:04 am]

[Ευφυή και Προσαρμοστικά ...
by grepanis
[June 11, 2026, 10:11:51 am]

[Γραφική] Λυμένα θέματα
by Roidos
[June 10, 2026, 21:37:48 pm]

Τι ακούτε αυτήν τη στιγμή...
by Karaμazoβ
[June 10, 2026, 18:42:33 pm]

[Η/Μ Πεδίο ΙΙ] Ανάλυση πα...
by Giannis Masterio
[June 09, 2026, 20:27:57 pm]

[ΣΑΕ ΙΙ] Απορίες σε ασκήσ...
by Hyperlaz02
[June 09, 2026, 12:01:45 pm]
Στατιστικά
Members
Total Members: 10402
Latest: anton
Stats
Total Posts: 1431473
Total Topics: 32024
Online Today: 1386
Online Ever: 18918
(April 06, 2026, 16:05:31 pm)
Users Online
Users: 42
Guests: 924
Total: 966
boukou
Natk
witchingHour
mkostomanolaki
esroussou
vasilikitsatsi
chriskazakos
mimaki
chris123
leolam
Mavromati
Anasta
Σβέλτο Φτυάρι
iliaskou
pkarakoe
spuros
Elbowshot
chrismzag
Tzikaman
mike1996
Tsn
Limpolits
giorgosth
vaggelisx
meletis
alexiosmara
Tom_b
gboutsi
mariaxalk
Naks404
ln07
georgeb
Katarameno
asemas
Alex Kosmas
migk
Maria Pap
femanak
Ulmo
Ted Kaczynski
kakousios
Εμφάνιση

Νέα για πρωτοετείς
Είσαι πρωτοετής;... Καλώς ήρθες! Μπορείς να βρεις πληροφορίες εδώ. Βοήθεια για τους καινούργιους μέσω χάρτη.
Κατεβάστε εδώ το Android Application για εύκολη πρόσβαση στο forum.
Ανεβάζετε τα θέματα των εξετάσεων στον τομέα Downloads με προσοχή στα ονόματα των αρχείων!

Νέα!
Η γραμματεία είναι ανοιχτή καθημερινά 12:00-13:30 Tongue
THMMY.gr > Forum > Μαθήματα Βασικού Κύκλου > 1ο Εξάμηνο > Δομημένος Προγραμματισμός (Moderators: Tasos Bot, tzortzis, Nekt, tony stank) > Εργασία E 2007
0 Members and 1 Guest are viewing this topic.
Pages: 1 ... 5 6 [7] Go Down Print
Author Topic: Εργασία E 2007  (Read 16560 times)
^^DaRk_HunTeR
Μόνιμος κάτοικος ΤΗΜΜΥ.gr
******
Gender: Male
Posts: 2149


0001 0010 0100 0010


View Profile
5η Εργασία-συζήτηση
« Reply #90 on: July 04, 2007, 02:02:37 am »

Quote from: A.B.US.E on June 29, 2007, 17:04:52 pm
Code:
/* This code Provided to you by A.B.US.E. (a.k.a. Addicted to Binary USage Entertainment)
 *
 * It's been an hour of stupidity and laming around until we got this piece of garbage
 * work. We, of course, obfuscated the code just to make sure you guys really try to
 * write that thing down.
 *
 * For those who believe that this program is a useless piece of junk that all it does
 * is irritating you... You're absolutely right...
 *
 * Kisses fly to all those who try hard to learn something out of these junks...
 * Flames fly to all those who enforce people to work on such useless programs...
 * Think differently...
 *
 * We will release the original code once your deadline is over... :-)
 * Until then enjoy the summer :-)
 */

/* $ABUSE.Code: test.c,v 1.0 2007/06/28 7:17:31 ABUSE Exp $ */

#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<unistd.h>

#define le float
#define lg int
#define lq void
#define lf for
#define ls if
#define lv break
#define lw main
#define lo fprintf
#define ln stderr
#define lr scanf
#define lp malloc
#define lm sizeof
#define lt memset

le* *ld;lg*lh;lg lc;lq lu(lq){lg la,lb,li,lk;le lj;lf(la=0;la<lc;la++
){ls(la+1==lc)lv;lf(lb=0;lb<lh[la];lb++){lj=ld[la][lb];lf(li=la+1;li<
lc;li++){lf(lk=0;lk<lh[li];lk++){ls(lj==ld[li][lk])ld[li][lk]=0;}}}}}
lg lw(lq){le lj, *lx;lg la,lb,ll;lo(ln,"\x54\x79\x70\x65\x20\x74\x68"
"\x65\x20\x6e\x75\x6d\x62\x65\x72\x20\x6f\x66\x20\x53\x74\x61\x74\x69"
"\x6f\x6e\x73\x20\x3a\x20");lr("\x25\x69",&lc);lh=(lg* )lp(lc*lm(lg));
lt(lh,0,lm(lg) *lc);ld=(le* * )lp(lc*lm(le* ));lt(ld,0,lc*lm(le* ));
lf(la=0;la<lc;la++){lo(ln,"\x54\x79\x70\x65\x20\x74\x68\x65\x20\x6e"
"\x75\x6d\x62\x65\x72\x20\x6f\x66\x20\x66\x72\x65\x71\x75\x65\x6e\x63"
"\x69\x65\x73\x20\x66\x6f\x72\x20\x73\x74\x61\x74\x69\x6f\x6e\x20\x25"
"\x64\x20\x3a\x20",la);lr("\x25\x69",&lb);lh[la]=lb;ld[la]=(le* )lp(
lb*lm(le));lf(ll=0;ll<lb;ll++){lo(ln,"\x54\x79\x70\x65\x20\x74\x68"
"\x65\x20\x66\x72\x65\x71\x75\x65\x6e\x63\x79\x20\x25\x64\x20\x66\x6f"
"\x72\x20\x73\x74\x61\x74\x69\x6f\x6e\x20\x25\x64\x20\x3a\x20",ll,la);
lr("\x25\x66",&lj);ld[la][ll]=lj;}}lu();lf(la=0;la<lc;la++){lf(lb=0;
lb<lh[la];lb++){ls(ld[la][lb])lo(ln,"\x53\x74\x61\x74\x69\x6f\x6e\x20"
"\x25\x64\x20\x63\x61\x6e\x20\x67\x65\x74\x20\x66\x72\x65\x71\x75\x65"
"\x6e\x63\x79\x20\x25\x66\x20\x28\x25\x64\x29\n",la,ld[la][lb],lb);}}
}

Quote of the month :
Quote from: Bo@rD-RiDeR on June 27, 2007, 16:11:51 pm
έστω i η σειρά και j η στήλη

Τότε 

scanf(" % f ", & p [ i ] [j ] );
ή
scanf(" % f ", ( p [ i]  + j ) );
ή
scanf(" % f ", ( * ( p + i ) + j ) );

'ολα το ίδιο είναι,διαλέγεις κ παίρνεις! Tongue

Best regards...

Addicted to Binary USage Entertainment...
"Sniffing your bits since 1952..."
the time has come Tongue let us see.................enlighten us
Logged

Without order nothing can exist without chaos nothing can evolve

Timeo hominem unius libri
The minstrel
A.B.US.E
Αρχάριος/Αρχάρια

Gender: Male
Posts: 3



View Profile WWW
5η Εργασία-συζήτηση
« Reply #91 on: July 04, 2007, 14:59:41 pm »

Quote
We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty, and the pursuit of Happiness. ... hat whenever any Form of Government becomes destructive of these ends, it is the Right of the People to alter or to abolish it, and to institute new Government, having its foundation on such principles and organizing its powers in such form, as to them shall seem most likely to effect their Safety and Happiness.
The Decleration of Independence - July 4th, 1776

We decided to post two codes one that uses realloc() and one that doesn't Smiley

The obfuscated source code came from the one which doesn't use realloc().

Both programs work Smiley

Some Remarks :
What one should do here is to create a pointer that each of its members will hold memories to other pointers. Memory is allocated linearly (using malloc()) and thus the pointers can be used as arrays. Note that after each allocation we call memset() to initialize to 0 unless we immediately initialize our data by other means.
Using stderr instead of stdout allows for unbuffered output (thus we use fprintf() instead of printf()). That's an explanation cause some people got really perplexed with this.. Tongue

Have fun and ask any questions here Smiley

Without realloc() :
Code:
/* This code Provided to you by A.B.US.E. (a.k.a. Addicted to Binary USage Entertainment)
 *
 * It's been an hour of stupidity and laming around until we got this piece of garbage
 * work. We, of course, obfuscated the code just to make sure you guys really try to
 * write that thing down.
 *
 * For those who believe that this program is a useless piece of junk that all it does
 * is irritating you... You're absolutely right...
 *
 * Kisses fly to all those who try hard to learn something out of these junks...
 * Flames fly to all those who enforce people to work on such useless programs...
 * Think differently...
 *
 * We will release the original code once your deadline is over... :-)
 * Until then enjoy the summer :-)
 */

/* $ABUSE.Code: t.c,v 1.0 2007/06/28 19:17:31 ABUSE Exp $ */

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

float **stations_freqs;
int *n_freqs;
int station_num;

/* Check all frequencies as follows :
 * Take current station and zero out all matching frequencies to the
 * above stations. Frequencies that are zero should not be checked.
 */
void check (void)
{
int i, c, s, x;
float freq;

for (i = 0; i < station_num; i++)
{
if (i + 1 == station_num)
break;

for (c = 0; c < n_freqs[i]; c++)
{
freq = stations_freqs[i][c];

/* Speed Hack */
if (!freq)
continue;

for (s = i+1; s < station_num; s++)
{
for (x = 0; x < n_freqs[s]; x++)
{
if (freq == stations_freqs[s][x])
stations_freqs[s][x] = 0;
}
}
}
}
}

int main (void)
{
float freq, *pos;
int i, c, p;

/* Read the number of Stations */
fprintf(stderr, "Type the number of Stations : ");
scanf("%i", &station_num);

n_freqs = (int *)malloc(station_num * sizeof(int));
memset(n_freqs, 0, sizeof(int) * station_num);

stations_freqs = (float **)malloc(station_num * sizeof(float *));
memset(stations_freqs, 0, station_num * sizeof(float *));

/* Now for each station read the number of freqs
* then read each freq.
*/

for (i = 0; i < station_num; i++)
{
fprintf(stderr, "Type the number of frequencies for station %d : ", i);
scanf("%i", &c);
n_freqs[i] = c;

/* Allocate enough space for them */
stations_freqs[i] = (float *)malloc(c*sizeof(float));

/* Read them and place them */
for (p = 0; p < c; p++)
{
fprintf(stderr, "Type the frequency %d for station %d : ", p, i);
scanf("%f", &freq);
stations_freqs[i][p] = freq;
}
}

check();

for (i = 0; i < station_num; i++)
{
for (c = 0; c < n_freqs[i]; c++)
{
if (stations_freqs[i][c])
fprintf(stderr, "Station %d can get frequency %f (%d)\n", i, stations_freqs[i][c], c);
}
}

return 0;
}

With realloc() :
Code:
/* This code Provided to you by A.B.US.E. (a.k.a. Addicted to Binary USage Entertainment)
 *
 * It's been an hour of stupidity and laming around until we got this piece of garbage
 * work. We, of course, obfuscated the code just to make sure you guys really try to
 * write that thing down.
 *
 * For those who believe that this program is a useless piece of junk that all it does
 * is irritating you... You're absolutely right...
 *
 * Kisses fly to all those who try hard to learn something out of these junks...
 * Flames fly to all those who enforce people to work on such useless programs...
 * Think differently...
 *
 * We will release the original code once your deadline is over... :-)
 * Until then enjoy the summer :-)
 */

/* $ABUSE.Code: t-realloc.c,v 1.0 2007/07/02 16:18:43 ABUSE Exp $ */

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

float **stations_freqs;
int *n_freqs;
int station_num;

/* Check all frequencies as follows :
 * Create a new array. Any frequency that did not
 * match is qualified to enter that array. This is
 * called straight insertion. We simply keep the new
 * size of that array and realloc() it later.
 * Make sure to free() the old array before assigning the
 * new address to it.
 */
void check (void)
{
int i, c, s, x, n_f;
float freq, *freqs, *p;

for (i = 0; i < station_num; i++)
{
if (i + 1 == station_num)
break;

for (c = 0; c < n_freqs[i]; c++)
{
freq = stations_freqs[i][c];

/* Speed Hack */
if (!freq)
continue;

for (s = i+1; s < station_num; s++)
{
n_f = 0;
freqs = (float *)malloc(n_freqs[s] * sizeof(float));
memset(freqs, 0, n_freqs[s] * sizeof(float));

for (x = 0; x < n_freqs[s]; x++)
{
if (freq != stations_freqs[s][x])
{
freqs[n_f] = stations_freqs[s][x];
n_f++;
}
}

p = (float *)realloc(freqs, n_f * sizeof(float));
free(stations_freqs[s]);
stations_freqs[s] = p;
n_freqs[s] = n_f;
}
}
}
}

int main (void)
{
float freq, *pos;
int i, c, p;

/* Read the number of Stations */
fprintf(stderr, "Type the number of Stations : ");
scanf("%i", &station_num);

n_freqs = (int *)malloc(station_num * sizeof(int));
memset(n_freqs, 0, sizeof(int) * station_num);

stations_freqs = (float **)malloc(station_num * sizeof(float *));
memset(stations_freqs, 0, station_num * sizeof(float *));

/* Now for each station read the number of freqs
* then read each freq.
*/

for (i = 0; i < station_num; i++)
{
fprintf(stderr, "Type the number of frequencies for station %d : ", i);
scanf("%i", &c);
n_freqs[i] = c;

/* Allocate enough space for them */
stations_freqs[i] = (float *)malloc(c*sizeof(float));

/* Read them and place them */
for (p = 0; p < c; p++)
{
fprintf(stderr, "Type the frequency %d for station %d : ", p, i);
scanf("%f", &freq);
stations_freqs[i][p] = freq;
}
}

check();

for (i = 0; i < station_num; i++)
{
if (!n_freqs[i])
continue;

for (c = 0; c < n_freqs[i]; c++)
{
if (stations_freqs[i][c]) /* Sanity Check */
fprintf(stderr, "Station %d can get frequency %f (%d)\n", i, stations_freqs[i][c], c);
}
}

return 0;
}

Quote
Blessed is he who, in the name of charity and good will, shepherds the weak through the Valley of Darkness; for he is truly his brother's keeper, and the finder of lost children.
Ezekiel 25:17
Logged

...America’s cryptologic organization.
anonymous-root
Veteran
Καταστραμμένος
******
Posts: 8574


What do you want to troll today?


View Profile
5η Εργασία-συζήτηση
« Reply #92 on: July 04, 2007, 15:03:04 pm »

@ABUSE θα μπορούσες να γράφεις ελληνικά; Ευχαριστούμε.  Smiley



@ ΠΟΙΟΣ ΣΥΓΧΩΝΕΥΣΕ ΤΑ ΘΕΜΑΤΑ ΤΩΝ ΕΡΓΑΣΙΩΝ????
Logged
SolidSNK
Αbsolute ΤΗΜΜΥ.gr
*******
Gender: Male
Posts: 4617


free()'d and attuned


View Profile
5η Εργασία-συζήτηση
« Reply #93 on: July 04, 2007, 15:46:31 pm »

Quote from: A.B.US.E on July 04, 2007, 14:59:41 pm
Using stderr instead of stdout allows for unbuffered output (thus we use fprintf() instead of printf()). That's an explanation cause some people got really perplexed with this.. Tongue
Y I already got that, u don't have to bang me in teh head...

What I liked most in ur code was the 'speed hack', I knew my code there was sloppy and needed smth like that to minimize the execution time Smiley

Where's ur frustrating 'constant-party' code now anywayz?
Logged

"Savior, conqueror, hero, villain. You are all things, Revan, and yet you are nothing. In the end you belong to neither the light nor the darkness. You will forever stand alone."
^^DaRk_HunTeR
Μόνιμος κάτοικος ΤΗΜΜΥ.gr
******
Gender: Male
Posts: 2149


0001 0010 0100 0010


View Profile
5η Εργασία-συζήτηση
« Reply #94 on: July 04, 2007, 20:12:49 pm »

btw memset()"should have a prototype" is not recognized by my compilers Tongue neither <unistd.h>"unable to open".....borland C++ (and dev C++)
Logged

Without order nothing can exist without chaos nothing can evolve

Timeo hominem unius libri
The minstrel
^^DaRk_HunTeR
Μόνιμος κάτοικος ΤΗΜΜΥ.gr
******
Gender: Male
Posts: 2149


0001 0010 0100 0010


View Profile
5η Εργασία-συζήτηση
« Reply #95 on: July 04, 2007, 20:21:26 pm »

Quote from: anonymous-root on July 04, 2007, 15:03:04 pm
@ABUSE θα μπορούσες να γράφεις ελληνικά; Ευχαριστούμε.  Smiley



@ ΠΟΙΟΣ ΣΥΓΧΩΝΕΥΣΕ ΤΑ ΘΕΜΑΤΑ ΤΩΝ ΕΡΓΑΣΙΩΝ????
οι mods του topic προφανως Tongue
Logged

Without order nothing can exist without chaos nothing can evolve

Timeo hominem unius libri
The minstrel
Καμένος
Μόνιμος κάτοικος ΤΗΜΜΥ.gr
******
Gender: Male
Posts: 2322


View Profile
5η Εργασία-συζήτηση
« Reply #96 on: July 05, 2007, 18:31:27 pm »

Quote from: A.B.US.E on July 04, 2007, 14:59:41 pm
What one should do here is to create a pointer that each of its members will hold memories to other pointers.

Ναί.. κρατάει αναμνήσεις σε άλλους pointers.. Τι το παίζεις αμερικανάκι αφού δε τραβάει??
Logged
Wanderer
Καταστραμμένος
********
Gender: Male
Posts: 5230


Othoum Endron Saous


View Profile
5η Εργασία-συζήτηση
« Reply #97 on: July 06, 2007, 19:54:54 pm »

Αναμνήσεις μιας ζωής...για πάντα καταχωρημένοι...μέσα στη μεταβλητή...ποτέ μή δεσμευμένη Cheesy Grin
Logged

Preserve and keep us safe this night     *and our innocence made fun of justice*

Once we dreamt of everything
united by our love
There's a place for everyone
so we scream "Liberta"
Pages: 1 ... 5 6 [7] Go Up Print
Jump to:  

Powered by SMF | SMF © 2006-2009, Simple Machines LLC
Scribbles2 | TinyPortal © Bloc | XHTML | CSS
Loading...