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

بليز ساعدوني

بدأه ريش احمر في 17 أبريل 2011 · 4 رد · 783 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

لسلام عليكم

ساعدوني في الحل سؤال الشيت :P تكفون علية درجات كبيرة وتسليم يوم الثلاثاء :cry:

Write a program that print in screen a tree with its height taken from user by entering number of 4 digits and find

the odd numbers then calculate the sum of odd numbers so he get the height of tree?

For example:

User enters 2331 the odd numbers are 3 ,3 and 1 the sum of them is 10 so it should print in screen this shape:

*

***

*****

*******

*********

***********

*************

***************

*****************

*******************

*******

*******

*******

If he enters 1316 the sum of odd number is 5 the shape should be like this:

*

***

*****

*******

*********

***

***

هذة محاولتي

# include <iostream.h>

void main( )

{

int i , j ;

for (i =1; i<= 3 ; i++)

{

for( j = 1 ; j <= 4 ; j++)

{

cout << i ;

cout << j<< endl;

}

cout << endl;

}بليز درو علي :mellow:

تم تعديل هذه المشاركة بواسطة ريش احمر في 17 أبريل 2011 في 16:05

#2

3+3+1=10 ???

#3

اولاً اعتقد ان المثال الاول غلط لان مجموع الاعداد الفرديه يساوي 7 ، وكذلك ما هي الطريقه التي تحسب بها عرض الساق ؟؟

#include<iostream.h>

int main ()
{
	int i,j,k,sum=0,temp;
	cin>>i;

	while(i!=0)
	{
		temp=i%10;
		if(temp%2==1)
			sum+=temp;
		i/=10;
	}

	for(j=0;j<sum;j++)
	{
		for(k=0;k<j*2+1;k++)
			cout<<"*";
		cout<<endl;
	}
	cout<<"***\n***\n***\n";
	return 0;
}
#4

ســوري ع غلط

عدلت موضوع :unsure:

تم تعديل هذه المشاركة بواسطة ريش احمر في 17 أبريل 2011 في 16:07

#5

انت لم تعدل شيء بل نقلت بشكل صحيح ، مازال نفس الغلط موجود كذلك ام تحدد طريقه ايجاد قيمه عرض الشجره !!!!!!

#include<iostream.h>
#include <iomanip.h>

int main ()
{
	int i,j,k,sum=0,temp;
	cin>>i;

	while(i!=0)
	{
		temp=i%10;
		if(temp%2==1)
			sum+=temp;
		i/=10;
	}

	for(j=0;j<sum;j++)
	{
		cout<<setw(sum-j);
		for(k=0;k<j*2+1;k++)
			cout<<"*";
		cout<<endl;
	}

	for(i=0;i<3;i++)
	{
		cout<<setw(sum+2);
		cout<<"***\n";
	}

	return 0;
}

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