![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Aug 2004
Location: The Netherlands
Posts: 111
Rep Power: 5
![]() |
Program To Get The Day By Giving Month And Date
hi all,
i was browsing some sites this afternoon and someone needed to write a program for his homework, he posted the complete assignment in the hope someone would do it for him.... Well, i did (i was bored at work). here it is: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * File: day.c * * * * Purpose: getting a month and date as input, outputting the day * * * * Usage: day.exe <month> <date> * * * * Copyright (C) 2004 Scorpius, scorpius_unknown@yahoo.com, all rights reserved * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation; either version 2 * * of the License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include <stdio.h> #include <strings.h> int main(int argc,char *argv[]) { /*first arguments checking*/ if (argc<3) { printf("Too few arguments, usage: %s <month> <date>",argv[0]); return 1; } if (argc>3) { printf("Too many arguments, usage: %s <month> <date>",argv[0]); return 1; } /*now for the actual program*/ const char *months[]={"jan","feb","mar","apr","may","jun","jul","aug","sep","okt","nov","dec"}; const char *days[]={"monday","tuesday","wednesday","thursday","friday","saturday","sunday"}; const int zero_th[]={2,4,4,6,0,2,3,4,0,1,3,4}; int day=atoi(argv[2]); int i,count=0,int_months=0; char buf[strlen(argv[1])]; strcpy(buf,argv[1]); if(buf[3]!='\0') { printf("Usage: %s <month> <date>",argv[0]); return 1; } for (i=0;i<12;i++) { if (strcmp(buf,months[i])==0) { int_months=i; break; } else { count++; } } if (count>11) { printf("Unrecognized Month [%s]: use jan, feb, mar, etc",buf); return 1; } if ((day<1)||(day>31)) { printf("Usage: %s <month> <date>",argv[0]); return 1; } i=((day+int_months+zero_th[int_months])%7); printf("%s",days[i]); return 0; } perhaps it might be usefull to someone , who knows, at least i have another program ![]()
__________________
http://www.white-scorpion.nl |
|
|
|
|
|
#2 |
|
Programming Guru
![]() ![]() ![]() |
<RANT>
I hate students that come in and just post a homework assignment, no attempt at solving it themselves. No effort on there part, I hope they all fail. Because if they cheat their way through school, they'll get a job in the field, if they're lucky, then their incompetence will get them fired. Besides, there is code to do this particular thing, plastered all around the internet, they probably didn't even bother to use google. </RANT> lol..
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#3 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
Yea. I usually try to do all my homework before I ask, no matter what the subject is. Of course there are times where I just get lazy, but I try not to make that a habit. I make sure to do my own homework for computer science, though, my favorite class
. I don't mind helping people with their homework when I can, I just feel if they don't do it themselves they are only hurting themselves. I'll help them out, but they won't gain much out of it except the grade.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower |
|
|
|
|
|
#4 |
|
Hobbyist Programmer
Join Date: Aug 2004
Location: The Netherlands
Posts: 111
Rep Power: 5
![]() |
well, i don't really care helping them, it's just another experience for me in programming, my biggest problem is thinking about what kind of program i'm going to write, and since it is only 3 months ago since i started programming, i see it as an assignment for me too....
as for the students, well, if they want to get the answer by someone else, let them. they will have to take an exam and nobody is going to be there to help them .but hey, the reason i posted it is because maybe, someone would find it usefull for some kind of script or something, and since i wrote it myself (although it was not my idea), i don't have to worry about copyright ![]()
__________________
http://www.white-scorpion.nl |
|
|
|
|
|
#5 |
|
Programming Guru
![]() ![]() ![]() |
I have no problems answering questions for students... However, I simply expect them to attempt to solve it on their own work. Effort is required. If they are willing to put forth the effort to learn, they need to change majors, as this industry constantly changes and they will be required to learn new technologies, etc.
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#6 | |
|
Hobbyist Programmer
Join Date: Aug 2004
Location: The Netherlands
Posts: 111
Rep Power: 5
![]() |
Quote:
that's why it is up to themselves, if they are stupid enough to ask questions like that, they WILL fail the exam. it's their own fault and their own responsibility.
__________________
http://www.white-scorpion.nl |
|
|
|
|
|
|
#7 |
|
Programmer
Join Date: Dec 2004
Posts: 87
Rep Power: 4
![]() |
Guys, I'm not a lazy person at all. I always attempt my assignments. However, people aren't looking at the future with their exams and things, because maybe some people are only taking the class for a requirement or a credit or something.
So when someone asks for help, help him or don't help him, but don't bash his reasons for asking for help. There have been a couple times when I have no clue where to start. |
|
|
|
|
|
#8 |
|
Newbie
|
I like cheaters; they give me deserving victims to antagonize and to fail.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|