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

سؤال عن ال Array عارفة ان حلي غلط بس شووفوا كيييف ؟؟؟

بدأه miss totah في 15 مايو 2009 · 5 رد · 822 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

هذا سؤال عن الــ Array

اول كود اسويه بالارري

عارفة انه غلط وانا كمان مافهمت السؤال زيين

بس سويت كود على السريييييييع

هذا السؤال

Write a C++ program that reads a sequence of characters ends with '$' that represents a

floating – point number.

Your program should divide this sequence into :

• A sign (+,-)

• The integer part ( the part before the DOT).

• The decimal part ( the part after the DOT).

For simplicity, assume that the user will not enter a non-valid characters ( letters,

spaces … ). For example if the user input is -12.45$ , your program should display :

• In main, define a character array of maximum size 256.

• Provide readArray(char arr[]) function that reads a sequence of characters

representing the floating point from the user until he/she enters '$' . ( Hint : use

getline function).

• Provide DivideFloat(char arr[]) function that prints the components of a

floating point number stored in arr.

وهذه المحاااولة

#include <iostream>

#include <iomanip>

using namespace std;

void readarray(char arr[])

{

double number;

cin.getline(number);

}

void dividfloat(char arr[])

{

readarray(arr[]);

cout<<showpos<<number;

cout<<" The Integer Part is : "<<static_cast<int>(number);

if(number<0)

cout<<" The Number is Negative ";

else

cout<<" The Number is Positive";

}

int main()

{

double arr[256];

dividfloat(arr[]);

return 0 ;

}

#2

السلام عليكم

يعنى لو أدخل المستخدم

-125.548$ يكون الخارج

-

125

548

؟؟؟؟؟؟

لو كان هو دا المطلوب

فالبرنامج يكون كالآتى

#include <iostream>
 #include <string.h>
 using namespace std;
 void ReadArray(char arr[])
 {
	 cin.getline(arr,256);
 }
 void DivideFloat(char arr[])
 {
	 int i=0;
	 if(arr[0]=='-') {
		 cout<<'-'<<endl;
		 i++;
	 }
	 else
		 cout<<'+'<<endl;
	 do {
		 cout<<arr;
		 i++;
	 } while(arr!='.'); 
	 cout<<endl;
	 i++;
	 do {
		 cout<<arr;
		 i++;
	 } while(arr!=' );
 }
 int main()
 {
	 char arr[256];
	 ReadArray(arr);
	 DivideFloat(arr);
	 cout<<endl;
	 return 0;
 }

سلام

تم تعديل هذه المشاركة بواسطة amin_mu123 في 15 مايو 2009 في 15:17

اللهم صل على سيدنا محمد وعلى آله وصحبه وسلم

#3

هو يطلع لك

كالآتي

مثلا :

The number is negative

Integer part is 12

Decimal part is 45

#4

يمكنك التعديل على الكود ببساطه

بدلا من كتابة الإشاره فى

  if(arr[0]=='-') {
		 cout<<'-'<<endl;
		 i++;
	 }
	 else
		 cout<<'+'<<endl;

يمكن كتابة positive او negative

وقبل do while الأولى يمكن كتابة Integer part is

وقبل do while الثانيه يمكن كتابة

Decimal part is

اللهم صل على سيدنا محمد وعلى آله وصحبه وسلم

#5

شكرا جزيييييييييلا

جزيت خيرا

#6

الاخوات شوشو-22 و miss totah ,, هذا منتدى علمي ولا مجال للمشادات الكلامية ... علم ؟ :blush:

llback.jpg

اشهد ان لا إله إلا الله وان محمدا ً رسول الله

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