شعبان المدير
عدد المساهمات : 7712 تاريخ التسجيل : 16/06/2010 الموقع : المزاج : الحمد لله
| موضوع: كود تقويم calendar code in C الأربعاء 19 أكتوبر - 5:31 | |
| كود تقويم calendar code in C مرحبا انا عملت هل الكود بلغة C++ للتقويم وأي سؤال او استفسار انا جاهز - الكود:
-
[color=indigo] #include <iostream.h> #include <stdlib.h> int myear; int i = 1; int week=1; int hd; unsigned short int proti_mera; bool leapyear(unsigned short int year)
{ if(year % 100 != 0) return (year % 4 == 0); else return (year % 400 == 0); }
void menu()
{ cout<<"Insert the year : \n"; cin>>myear; cout<<endl; cout<<"Which is the first day of the year ?\n"; cout<<"1. Monday\n"; cout<<"2. Tuesday\n"; cout<<"3. Wednesday\n"; cout<<"4. Thursday\n"; cout<<"5. Friday\n"; cout<<"6. Saturday\n"; cout<<"7. Sunday\n"; cout<<endl; do
{ cout<<"Press (1..7) : "; cin>>proti_mera; if (!((proti_mera > 0) && (proti_mera < 8))) continue; } while (!((proti_mera > 0) && (proti_mera < 8))); cout<<endl; cout<<"How many days would you like me to print ?\n"; do
{ if (leapyear(myear))
{ cout<<"Press (1..366) : "; cin>>hd; if (!((hd > 0) && (hd <= 366))) continue; else break; } if (!leapyear(myear))
{ cout<<"Press (1..365) : "; cin>>hd; if (!((hd > 0) && (hd <= 365))) continue; else break; } } while (1); cout<<endl; }
void display_week()
{ cout.width(15); cout<<week++<<" Week\n"; cout<<endl; }
void pause_page()
{ if (i % 7 == 0)
{ cout<<endl; system("PAUSE"); cout<<endl; display_week(); } }
int main()
{ char mdays[7][10] = {"Monday","Tuesday","Wednesday","Thursday","Friday ","Saturday","Sunday"}; char mmonths[12][12] = {"January","February","March","April","May","June" ,"July","August","September","October","November", "December"}; int disdays[12] = {31,29,31,30,31,30,31,31,30,31,30,31}; int udisdays[12] = {31,28,31,30,31,30,31,31,30,31,30,31}; int dday = 1; int mmonth=0; menu(); int mday = proti_mera-1;
display_week(); for(i;i<=hd;i++)
{ cout<<i<<""; cout.width(5); cout<<mdays[mday++]<<" "<<dday++<<" "<<mmonths[mmonth]<<" "<<myear<<endl; if (leapyear(myear))
{ if(dday == disdays[mmonth]+1)
{ dday=1; mmonth++; } } if (!leapyear(myear))
{ if(dday == udisdays[mmonth]+1)
{ dday=1; mmonth++; } }
if (mday >= 7) mday=0; pause_page(); } cout<<endl; return 0; } [/color]
| |
|
ديدى عضو فضى
عدد المساهمات : 264 تاريخ التسجيل : 09/11/2010
| موضوع: رد: كود تقويم calendar code in C الجمعة 28 أكتوبر - 18:02 | |
| كل الشكر للمجهود الجميل والموضوع الرائع تسلم الايادى دمت لنا ودام تالقك الدائم مع خالص ودي وتقديري | |
|