Difference between revisions of "Решения"
From Ilianko
Line 1: | Line 1: | ||
− | == Задача 5. | + | == Задача 5.8 == |
<code><pre> | <code><pre> | ||
/*********************************************************************\ | /*********************************************************************\ |
Revision as of 10:47, 9 April 2011
Задача 5.8
/*********************************************************************\
* Title: wide char string bubble sort
* Author: ilianko
*
\*********************************************************************/
#include <stdio.h>
#include <wchar.h>
#include <locale.h>
#define BROI_DUMI 4
#define DYLZHINA_NA_DUMA 16 // max broj simvoli
int main ()
{
setlocale(LC_CTYPE, ""); // Зареждане на локалните параметри
//wchar_t words[DUMI][DYLZHINA_NA_DUMА] = {L"strawberry",L"orange",L"mango",L"apple"};
wchar_t words[BROI_DUMI][DYLZHINA_NA_DUMA] = {L"ягода",L"портокал",L"ябълка",L"манго"};
printf(" %ls \n\n", words[0]);
int i,k;
wchar_t temp[16];
for(k=1;k < BROI_DUMI;k++)
{
for(i = BROI_DUMI-1; i > 0; i--)
{
if( wcscmp(words[i],words[i-1]) < 0)
{
wcscpy ( temp, words[i]);
wcscpy ( words[i], words[i-1]);
wcscpy ( words[i-1], temp);
}
}
}
//Izvezhdane na rezultata
for (i = 0 ; i < BROI_DUMI; i++)
printf("%ls \n", words[i]);
return 0;
}