Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- struct book_t{
- char name[50];
- int year;
- int copies;
- }a;
- struct bookstore_t{
- struct book_t books[10];
- int broi;
- }*bs;
- int sorted_add(struct bookstore_t* store, struct book_t newbook){
- int i, ii;
- if(store->broi < 10){
- for(i=0; i<10; i++){
- if(newbook.year < store->books[i].year){
- for(ii=10; ii>i; i--){
- store->books[ii] = store->books[ii-1];
- }
- store->books[i] = newbook;
- return i;
- }
- }
- }
- else return -1;
- }
- int main(){
- gets(a.name);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement