Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.66 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. struct book_t{
  4.     char name[50];
  5.     int year;
  6.     int copies;
  7. }a;
  8.  
  9. struct bookstore_t{
  10.     struct book_t books[10];
  11.     int broi;
  12. }*bs;
  13.  
  14. int sorted_add(struct bookstore_t* store, struct book_t newbook){
  15.     int i, ii;
  16.     if(store->broi < 10){
  17.         for(i=0; i<10; i++){
  18.             if(newbook.year < store->books[i].year){
  19.                     for(ii=10; ii>i; i--){
  20.                         store->books[ii] = store->books[ii-1];
  21.                     }
  22.                     store->books[i] = newbook;
  23.                 return i;
  24.             }
  25.         }
  26.     }
  27.     else return -1;
  28. }
  29.  
  30. int main(){
  31.     gets(a.name);
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement