| | |
The Gregorian Calendar
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2005
Posts: 1
Reputation:
Solved Threads: 0
Hi, this is my first time here and I have a problem. I am trying to write a C++ program in Unix that gives me the Gregorian calendar with exceptions to leap year. I have all of my algorithms for calculating days, printing out the months, and such. My problem is that I need a loop in my int main function that loops the input in a way in which it would allow my days and day numbers to sync up and print them in columns and rows.....any suggestions??
•
•
Join Date: Jul 2005
Posts: 244
Reputation:
Solved Threads: 5
There's a number of ways to do this. What you're looking for is constant-width columns, correct? For the dates, this isn't too bad, because you just have to do a check based on if the value will be less than ten, and zero/space pad the value in formatting.
For the letters, though, things are a little harder.
Here's just one idea.
You could enumerate the days and months in an order based on the number of letters.
ie,
and then use the value of the enumeration to set how many spaces you'll need to format the columns correctly with an if statement.
For the letters, though, things are a little harder.
Here's just one idea.
You could enumerate the days and months in an order based on the number of letters.
ie,
C++ Syntax (Toggle Plain Text)
enum Month{MAY,JUNE,JULY,APRIL,MARCH}; //And so on...
![]() |
Similar Threads
- leap year (C)
- date conversion using php (PHP)
- 2038 Problem (C++)
- Calendar Creator (C)
- help with sort using Calendar class getting null pointer exception (Java)
- New Calendar !! (DaniWeb Community Feedback)
Other Threads in the C++ Forum
- Previous Thread: a double script array problem
- Next Thread: trim trailing spaces
| Thread Tools | Search this Thread |
api array arrays based binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






