Thread: Optimizing Number of Tables in a Room

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    null pointer Structure's Avatar
    Join Date
    May 2019
    Posts
    338
    In Theory...
    Code:
    #include <stdio.h>
    
    int main(int args,char *argv[]) {
    
        float roomWidth = 20, roomLength = 30;
        float tableWidth = 4, tableLength = 7;
        float spaceWidth = 4, spaceLength = 6;
    
        float floorSpace = (roomWidth*roomLength);
        float tableSize = ((tableWidth+(spaceWidth*2))*(tableLength+(spaceLength*2)));
        int tableCount = (floorSpace/tableSize);
    
        printf("In a room of size [%.2f x %.2f]. ", roomWidth,roomLength);
        printf("You have a total area of [%.2f]. ", floorSpace);
        printf("Considering tables that are [%.2f x %.2f], ", tableWidth,tableLength);
        printf("a width spacing of [%.2f] on both sides ", spaceWidth);
        printf("and a length spacing of [%.2f] on both sides. ", spaceLength);
        printf("Since a table and the space around it requires [%.2f]. ",tableSize);
        printf("You can fit a maximum of [%i] tables in the room. ", tableCount );
        printf("\n");
    
        return 0;
    };
    Last edited by Structure; 01-25-2020 at 11:16 AM. Reason: Changed spaceWidth/spaceHeight to accomodate both sides. duh
    "without goto we would be wtf'd"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Any Room For Improvement?
    By Clinthill98 in forum C++ Programming
    Replies: 2
    Last Post: 04-01-2010, 07:11 AM
  2. Is there a C++ Chat Room
    By kamitsuna in forum General Discussions
    Replies: 1
    Last Post: 02-25-2010, 12:45 AM
  3. C# chat room?
    By jackstrong in forum C# Programming
    Replies: 1
    Last Post: 03-19-2006, 06:32 PM
  4. C Chat Room
    By bnovc in forum C Programming
    Replies: 3
    Last Post: 06-26-2005, 08:42 PM
  5. A chat room?
    By Padawan in forum Networking/Device Communication
    Replies: 3
    Last Post: 11-19-2003, 07:32 PM

Tags for this Thread