الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

من يستخرج الغلط من هذا البرنامج سي بلس بلس

مغلق
بدأه mhaster007 في 9 أكتوبر 2004 · 1 رد · 450 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

البرنامج هو ::

write a C++ programe that :

display on the screen a nice title and a name as well

the programe reads from standard input stream (keyboard in this case) an integer value of six digits .for example :120704 or 31103(meaning 031103

this number is date . it is to be spilt as follows : the first two digits represent the day then the next two are the month and finally the last two are the year of century

for example : for 120704 the day is 12 the month is 7 and theyear is 4 for 31103 the day is 3 the month is 11 and the year is 3

display on screen the day as follows:

the date is 12 july 2004 for input 120704

or the date is 3 november 2003 for input 31103

if the date is not correct such as 420804 or 141404

هذا الي طلع معي:

#include <iostream.h>

void main ( ) {

int number,D, day, month, year, f, a;

cout << "\n\t TaMeR SaEeD \n\n ";

cout << "\n\n Enter Your Numbers \n";

cout << "\n The Date Will Appear To You\n:";

cin >> number;

D = number;

day = number / 10000;

number = number % 10000;

if (day<=31)

cout << "\n" << day;

if (day>=31)

cout << "\n ???????? ";

month = number / 100;

number = number % 100;

if (month==1)

cout << " January ";

if (month==2)

cout << " February ";

if (month==3)

cout << " March ";

if (month==4)

cout << " April ";

if (month==5)

cout << " May ";

if (month==6)

cout << " June ";

if (month==7)

cout << " July ";

if (month==8)

cout << " August ";

if (month==9)

cout << " September ";

if (month==10)

cout << " October ";

if (month==11)

cout << " November ";

if (month==12)

cout << " December ";

year = number % 100;

f = year + 1900;

if (year>=80)

cout << f << "\n\n";

a = year + 2000;

if (year<=10)

cout << a << "\n\n";

}

لكن ما زبط معي ايش الغلط والله ماني عارف ؟؟؟؟؟

#2

السلام عليكم,

البرنامج شغال تقريبا فهو ينقصه كتابة السنة وهو ربما مكتوب بطريقة شيئ ما طويلة.

وسأعطيك مثال هنا وقد اتبعت نفس طريقتك ويبقى فقط أن نزيد التحقق من الأعداد إن كانت حقيقة مثلا إن كان اليوم أقل من 31 إلى غير ذلك والسنة إذا كانت أقل من 10 يعني سنة 2000 وما فوق. وها هو الكود :

#include <iostream.h>
void main ( ) {
	char* cmonth[12]={"january","february","mars","april","mai","june","july","august",
  "september","october","november","december"};

int number,day, month, year,temp;

cout << "\n\t TaMeR SaEeD \n\n "; 

cout << "\n\n Enter Your Numbers \n";

cout << "\n The Date Will Appear To You\n:";

cin >> number;

//*********************************************
	day=number/10000;
	temp=number - day*10000;
	month=temp/100;
	year=temp-month*100;
	if (year >10)
	{
  year+=1900;
	}
	else 
	{
  year+=2000;
	}
	cout <<day<<" "<<cmonth[month-1]<<" "<<year<<"\n";
}

أتمنى أن يفيد وإلى اللقاء.

هذا الموضوع مغلق.

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…