Hirdetés
Új hozzászólás Aktív témák
-
Jester01
veterán
válasz
chabeee
#2916
üzenetére
Rengeteg módon. Például csinálsz egy struct-ot amiben benne van a magyar és az angol szó. Ezután qsort hívással, a megfelelő összehasonlító függvény megadásával, berendezed:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct entry
{
const char* eng;
const char* hun;
};
static int compare_entries(const void* a, const void* b)
{
const struct entry* e1 = a;
const struct entry* e2 = b;
return strcmp(e1->eng, e2->eng);
}
int main()
{
struct entry words[] = {
{ "dog", "kutya" },
{ "donkey", "szamar" },
{ "content", "tartalom" },
{ "apple", "alma" },
{ "good", "jo" },
{ "diamond", "gyemant" }};
const int count = sizeof words / sizeof words[0];
int i;
qsort(words, count, sizeof words[0], compare_entries);
for(i = 0; i < count; ++i)
{
printf("%s %s\n", words[i].eng, words[i].hun);
}
return 0;
}
Új hozzászólás Aktív témák
● olvasd el a téma összefoglalót!
● ha kódot szúrsz be, használd a PROGRAMKÓD formázási funkciót!
- NetApp StorageGrid SG5712 (NAJ-1502)- adattároló hdd nélkül -3 db
- HPE BladeSystem c7000 Enclosure (403321-B22)-without Blades -
- Intel Modular Server Chassis MFSYS25 adattároló --4x900GB HDD + 7x600GB HDD
- EMC 15-slot Disk Array Enclosure for DataDomain -15x3TB HDD- Adattároló - 2db van
- HPE UPS Extended Runtime Module R8000/3, R12000/3 compatible - kiegészitő modul -rackbe szerelhető
- 206 - Lenovo Legion Slim 7 (16IRH8) - Intel Core i7-13700H, RTX 4060
- Apple iPhone 11 Pro 64GB, Kártyafüggetlen, 1 Év Garanciával
- LG 65G5 - 65" OLED Tandem - 4K 165Hz & 0.1ms - MLA Plus - 4000 Nits - NVIDIA G-Sync - FreeSync
- BESZÁMÍTÁS! LG 29WP60G-B 29 75Hz IPS UWFHD 1ms monitor garanciával hibátlan működéssel
- Sosemhasznált! HP OmniBook 5 i7-1355U 16GB 1TB 16" FHD+ Gar.: 1 év
Állásajánlatok
Cég: Central PC számítógép és laptop szerviz - Pécs
Város: Pécs
Cég: Laptopműhely Bt.
Város: Budapest


