Решения

From Ilianko
Revision as of 09:10, 9 April 2011 by Anko (talk | contribs) (Created page with "== Задача 5.2 == /*********************************************************************\ * Title: wide char string bubble sort * Author: ilianko * \********************...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Задача 5.2

/*********************************************************************\

* Title: wide char string bubble sort
* Author: ilianko
* 

\*********************************************************************/

  1. include <stdio.h>
  2. include <wchar.h>
  3. include <locale.h>
  1. define BROI_DUMI 4
  2. 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;

}