Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- ///////////////////////////////////////
- int main()
- {
- int in_stack = 0,
- total_cost = 0,
- book_cost = 1000,
- count_books ;
- printf("Enter count of books: ");
- scanf("\n%d", &count_books);
- int i = 1;
- if(count_books < 0) printf("Wrong number.");
- else
- {
- for(; i <= count_books; i++)
- {
- total_cost += book_cost;
- book_cost -= 55;
- in_stack ++ ;
- if(in_stack == 7)
- {
- book_cost = 1000;
- in_stack = 0;
- }
- }
- printf("%2i books = %d\n", i-1, total_cost);
- }
- return 0;
- }
- /*
- #include <stdio.h>
- int main() {
- int count_books;
- int total_cost = 0, book_cost = 1000, in_stack = 0;
- printf("Enter count of books: ");
- scanf("\n%d", &count_books);
- if (count_books < 0) {printf("Wrong number.");}
- else {
- for (int i = 0; i <= count_books; i++) {
- printf("%i books = %d\n",i, total_cost);
- total_cost += book_cost;
- book_cost -= 55;
- in_stack++;
- if (in_stack == 7) {
- book_cost = 1000;
- in_stack = 0;
- }
- }
- }
- return 0;
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement