bla bla

by dodko on February 23rd, 2012
No notes
Syntax: No syntax
Show lines - Hide lines - Show in textbox - Download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #include <string.h>
  5. struct osoba{
  6. int osobne_cislo;
  7. char meno[10];
  8. };
  9.  
  10. void swap(struct osoba* a, struct osoba* b ){
  11. struct osoba c;
  12.  
  13. c = *a;
  14. *a = *b;
  15. *b = c;
  16. }
  17.  
  18. void napln_meno(char * zaciatok, int velkost) {
  19. int i;
  20. srand(time(NULL));
  21. for(i=0;i<velkost;i++)
  22. zaciatok[i]=(rand()% 25 + 'A');
  23. zaciatok[i] = '\0';
  24. }
  25. void napln_structury_vpoli(struct osoba* zaciatok, int velkost){
  26. int i,j;
  27. srand(time(NULL));
  28. for (i=0;i<velkost;i++){
  29.  
  30. napln_meno(zaciatok[i].meno,10);
  31. zaciatok[i].osobne_cislo=(rand()% 1000 + 8000);}
  32. }
  33.  
  34. void tlac_pole_struct(struct osoba* zaciatok, int velkost){
  35. int i;
  36. for(i=0;i<(velkost-1);i++)
  37. printf("%i %s\n",zaciatok[i].osobne_cislo,zaciatok[i].meno);
  38. }
  39.  
  40.  
  41. void bubble_sort_pre_struc(struct osoba* zac, int velkost){
  42.  
  43. }
  44.  
  45. int main( ){
  46. struct osoba a;
  47.  
  48.  
  49. a.osobne_cislo=8827;
  50. strcpy(a.meno,"Dodko");
  51. printf("%i ",a.osobne_cislo);
  52. printf("%s\n",a.meno);
  53.  
  54.  
  55.  
  56. /* struct osoba* poi;
  57.  
  58.  
  59. poi =&a;
  60. printf("%i ",poi->osobne_cislo);
  61. printf("%s\n\n\n",poi->meno);
  62. */
  63.  
  64. struct osoba pole_osob[20];
  65. char pole[20];
  66.  
  67. napln_structury_vpoli(pole_osob,20);
  68. tlac_pole_struct(pole_osob,20);
  69.  
  70.  
  71. // struct osoba* pole_adries[20];
  72. // Uloha 6.
  73. getchar();
  74. }
  75.  

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS