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

تمرين الآلة الحاسبة بلغة السي

بدأه MouhcineFD في 27 نوفمبر 2014 · 1 رد · 1,588 مشاهدة · في لغة C و ++C
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

لدي تمرين لكم مع بعض الأسئلة أتمنى المناقشة

 

صنع تطبيق آلة حاسبة بالعمليات الأربع الجمع الطرح الضرب القسمة مع الأقواس وامكانية حساب الأعداد بالفاصلة  بلغة السي القياسية  وفي الكونسول فقط

 

المدخلات

8-9.55*(6+11.23)/5*((-7)/65.54*(4+7))-5

المخرجات

8-9.55*(6+11.23)/5*((-7)/65.54*(4+7))-5 = 41.663657

بعد صنع التطبيق أجب على الأسئلة

1 ماهو مستوى صعوبة التمرين ؟

2 كم استغرقت من الوقت لأنهاء التطبيق ؟

3 هل المدة تتعلق بمستوى تفكيرك أم معرفتك باللغة ؟

4 هل استخدمت أفكار جديدة أم اعتمدت على أفكارسبق لك واستخدمتها ؟

5هل اعدت كتابة الطبيق من الصفر بأفكار جديد ؟ كم ؟

6 ما رأيك في التمرين ؟

 

أو

 

لمادا لم تجب على التمرين ؟

تم تعديل هذه المشاركة بواسطة MouhcineFD في 27 نوفمبر 2014 في 03:50

#2

اجابتي

 

1الصعوبة متوسط 

2 تقريبا 9 ساعات متواصلة أو أكتر

3 أرى أن المدة نسبتها الأكبر استهلكتها في التفكير

4 كل الأفكار التي استخدمتها لم يسبق لي أن فكرت فيها

5 نعم أعدت كتابته من الصفر مرتيين

5 أرى أنه تمرين جيد للمتمكنين من أساسيات اللغة ومن أجاب عليه وهو يعرف الاساسيات فقط للبرمجة أي المبتدئين فلهم مستقبل رهيب في البرمجة في حين أرى أنه مجرد لهو ببعض الحلقات والجمل الشرطية لبعض المحبين القدامى للغة

#include<stdio.h>#include<stdlib.h>#define lengthOfString 100typedef struct operand_s operand_s;struct operand_s{	double theOperand;	char theOperator;	int theDegree;	operand_s *nextOperand;};void intialization_operands(operand_s *myOperands, int nbrOperands){	for (int i = 0; i < nbrOperands; i++)	{		operand_s *newOperand = malloc(sizeof(*newOperand));		newOperand->theOperand = 0;		newOperand->theOperator = ' ';		newOperand->theDegree = 0;		newOperand->nextOperand = myOperands->nextOperand;		myOperands->nextOperand = newOperand;	}}int nmbrOfDigInOper(char *myOperation){	int theNumbre = 0;	for (int i = 0; myOperation != '\0'; i++)	{		if (myOperation >= 48 && myOperation <= 57)		{			theNumbre++;			while (myOperation >= 48 && myOperation <= 57 || myOperation == '.')			{				i++;			}		}	}	return theNumbre;}int first_treatment(char *myOperation, operand_s *myOperands){	int degree = 0, largDegree = 0;	operand_s *temporaryOp = myOperands;	for (int i = 0; myOperation != '\0'; i++)	{		if (myOperation == '(')		{			degree += 2;			if (degree > largDegree)				largDegree = degree;		}		else if (myOperation == ')')		{			degree -= 2;			temporaryOp->theDegree -= 2;		}		else if (myOperation >= 48 && myOperation <= 57)		{			temporaryOp->theDegree = degree;			temporaryOp->theOperand = strtod(&myOperation, NULL);			if (myOperation[i - 2] == '(')				temporaryOp->theOperand *= -1;			while (myOperation >= 48 && myOperation <= 57 || myOperation == '.')			{				i++;			}			i--;		}		else if (myOperation == '*' || myOperation == '/')		{			temporaryOp->theDegree++;			if (temporaryOp->theDegree > largDegree)				largDegree = temporaryOp->theDegree;			temporaryOp->theOperator = myOperation;			temporaryOp = temporaryOp->nextOperand;		}		else if (myOperation == '+' || myOperation == '-')		{			if (myOperation[i - 1] != '(')			{				temporaryOp->theOperator = myOperation;				temporaryOp = temporaryOp->nextOperand;			}		}	}	return largDegree;}void second_treatment(operand_s *myOperands, int largDegree){	operand_s *temporaryOp = myOperands, *operandADelet = NULL;	while (temporaryOp->nextOperand != NULL)	{		if (temporaryOp->theDegree == largDegree)		{			switch (temporaryOp->theOperator)			{			case '*':				temporaryOp->theOperand *= temporaryOp->nextOperand->theOperand;				break;			case '/':				temporaryOp->theOperand /= temporaryOp->nextOperand->theOperand;				break;			case '+':				temporaryOp->theOperand += temporaryOp->nextOperand->theOperand;				break;			case '-':				temporaryOp->theOperand -= temporaryOp->nextOperand->theOperand;				break;			}			temporaryOp->theOperator = temporaryOp->nextOperand->theOperator;			temporaryOp->theDegree = temporaryOp->nextOperand->theDegree;			operandADelet = temporaryOp->nextOperand;			temporaryOp->nextOperand = temporaryOp->nextOperand->nextOperand;			free(operandADelet);		}		else if (temporaryOp->theDegree != largDegree)			temporaryOp = temporaryOp->nextOperand;	}}int main(){	int nmbrOfDig, largDegree;	char theOperation[lengthOfString] = { ' ' };	operand_s *theOperands = malloc(sizeof(*theOperands));	theOperands->theOperand = 0;	theOperands->theOperator = ' ';	theOperands->theDegree = 0;	theOperands->nextOperand = NULL;	scanf("%s", theOperation);	nmbrOfDig = nmbrOfDigInOper((char*)&theOperation);	intialization_operands(theOperands, nmbrOfDig - 1);	largDegree = first_treatment((char*)&theOperation, theOperands);	while (largDegree >= 0)	{		second_treatment(theOperands, largDegree);		largDegree--;	}	printf("%s = %lf\n", theOperation, theOperands->theOperand);	free(theOperands);	return 0;}

تم تعديل هذه المشاركة بواسطة MouhcineFD في 27 نوفمبر 2014 في 03:50

1

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