سلامنقل قول:
اينجوري كه گفته بودي نوشتم ولي باز هم عددي مثل 14 رو ميگه كامل است!
Printable View
سلامنقل قول:
اينجوري كه گفته بودي نوشتم ولي باز هم عددي مثل 14 رو ميگه كامل است!
آخ پس فكر كنم من يادم رفته عدد كامل يعني چي!
فكر كردم عدد كامل عدديه كه غير از خودش و 1 به عدد ديگه اي هم بخش پذير باشه!!!
يكي بياد به من بيسواد بگه عدد كامل چي بود!!!
با سلام،
اعداد كامل طبق تعريف اعداديند كه مجموع مقسوم عليه هاي آنها (به غير از خودشان) با آن عدد برابر باشد.مثلا"
عدد 6 (با مقسوم عليه هاي 1و2و3و6)يك عدد كامل است:1+2+3=6
برنامه زير نيز كامل بودن يا نبودن عدد ورودي را كه از كاربر مي گيرد،تعيين ميكند.اميدوارم بدردت بخورد:
کد:#include <stdio.h>
void main(void)
{int a,i,m;
printf("Enter your number;");
scanf("%d",&a);
m=0;
for(i=1;i<=a/2;i++)
if(a%i==0)
m=m+i;
if(m==a)
printf("%d is a Complete number.",a);
else printf("%d is not a Complete number.",a);
}
موفق باشيد.
نقل قول:
سلام
دستت درد نكنه كار كرد.كاشكي مي گفتي ايراد كار من چي بوده.
اينجا:نقل قول:
البته فقط يه اشكال داشتي اون 2 تا غلط ديگه كه گرفتم براي دوباره كاري ايه كه مي شه حذفش كردکد:#include <iostream.h>
#include <conio.h>
int perfect(int);
int main()
{
int n;
cout<<"Enter a number:"<<'\n';
cin>> n;
perfect(n);
if(perfect(n))
cout<<"Your number is perfect.";
else
cout<<"Your number is imperfect.";
getch();
return 0;
}
int perfect(int num)
{
int j,sum=0 ;
for(j=1;j<num;j++)
{
num%j;
if(num%j==0)
sum=sum+j;
if(sum==num)
return num;
}
return 0;
}
برنامهای گرافيکی با استفاده مناسب از توابع برای کار با ماتريسها با اندازههاي مختلف (حداكثر 10) بنويسيد.
({1,2,...,10}Am*n, m,n) اين برنامه بايد شامل بخشهاي زير باشد:
الف) سه تابع جهت تعيين نوع ماتريس (قطری، بالا مثلثی و پايين مثلثی).
ب) دو تابع براي انجام عمليات جمع و ضرب دو ماتريس.
ج) توابعي محاسبه ترانهاده و تعيين دترمينان.
د) يك تابع جهت خواندن ماتريسها از فايلهای متنی ورودی. اطلاعات ماتريس اول (شامل ابعاد و عناصر آن) در Mat1.txt و اطلاعات ماتريس دوم در Mat2.txt ذخيره شوند.
ه) تابع(توابعي) براي نوشتن نتايج هر يك از عمليات بهصورت مطلوب در فايل متنی خروجی بنام Result.txt.
و) توابع بالا به صورت شي گرايي:18::41::44::42::42::23::23:
كسي نيست جواب منو بدددددددددددددددههههههههه ههههههههههههه
كمممممممم م م م م م ككك ك ك ك ك ك ك ك ك ك ك ك ك
يكي هست مشكلات اين كد را بهم بگه يا كد تصحيح شده را برام بذاره
كار اين كد اينه كه مانند دستگاه مختصات كار ميكنه و چهار نقطه (گوشه هاي يك مستطيل) رو به ما ميده و مي تونه توسط متد عضو GetArea محيط مستطيل هم بده
کد:#include <iostream>
using namespace std;
class Point
{
public:
int GetX() const;
int GetY() const;
void SetX(int x);
void SetY(int y);
private:
int itsX;
int itsY;
};
int Point::GetX() const
{
return itsX;
}
int Point::GetY() const
{
return itsY;
}
void SetX(int x)
{
itsX = x;
}
void SetY(int y)
{
itsY = y;
}
class Rectangle
{
public:
Rectangle(int top,int bottom,int right,int left);
~Rectangle();
int GetTop() const;
int GetBottom() const;
int GetRight() const;
int GetLeft() const;
void SetTop(int top);
void SetBottom(int bottom);
void SetRight(int right);
void SetLeft(int left);
Point GetUpperRight() const;
Point GetLowerRight() const;
Point GetUpperLeft() const;
Point GetLowerLeft() const;
void SetUpperRight(int location);
void SetLowerRight(int location);
void SetUpperLeft(int location);
void SetLowerLeft(int location);
int GetArea() const;
private:
int itsTop;
int itsBottom;
int itsRight;
int itsLeft;
Point itsUpperRight;
Point itsLowerRight;
Point itsUpperLeft;
Point itsLowerLeft;
};
Rectangle::Rectangle(int top,int bottom,int right,int left)
{
itsTop = top;
itsBottom = bottom;
itsRight = right;
itsLeft = left;
itsUpperRight.GetX(right);
itsUpperRight.GetY(top);
itsUpperLeft.GetX(left);
itsUpperLeft.GetY(top);
itsLowerRight.GetX(right);
itsLowerRight.GetY(bottom);
itsLowerLeft.GetX(left);
itsLowerLeft.GetY(bottom);
}
Rectangle::~Rectangle
{
}
int Rectangle::GetTop() const
{
return itsTop;
}
int Rectangle::GetBottom() const
{
return itsBottom;
}
int Rectangle::GetRight() const
{
return itsRight;
}
int Rectangle::GetLeft() const
{
return itsLeft;
}
void Rectangle::SetTop(int top)
{
itsTop = top;
}
void Rectangle::SetBottom(int bottom)
{
itsBottom = bottom;
}
void Rectangle::SetRight(int right)
{
itsRight = right;
}
void Rectangle::SetLeft(int left)
{
itsLeft = left;
}
int Rectangle::GetUpperRight() const
{
return itsUpperRight;
}
int Rectangle::GetLowerRight() const
{
return itsLowerRight;
}
int Rectangle::GetUpperLeft() const
{
return itsUpperLeft;
}
int Rectangle::GetLowerLeft() const
{
return itsLowerLeft;
}
void Rectangle::SetUpperRight(int location)
{
itsUpperRight = location;
}
void Rectangle::SetLowerRight(int location)
{
itsUpperLeft = location;
}
void Rectangle::SetUpperLeft(int location)
{
itsUpperLeft = location;
}
void Rectangle::SetLowerLeft(int location)
{
itsLowerLeft = location;
}
int Rectangle::GetArea() const
{
int Width = itsRight - itsLeft;
int Height = itsTop - itsBottom;
return (Width * Height);
}
int main()
{
Rectangle MyRectangle(50,20,80,50);
cout <<"Area = "<<MyRectangle.GetArea()<<endl;
cout <<"Upper Left X cordinate = "<<MyRectangle.GetUpperLeft.GetX<<endl;
return 0;
}
سلام من برای نوشتن پروژه اخر ترمم باید یرنامه یک ویرایشگر متن رو بنویسم و با مشکلاتی روبرو شدم این ویرایشگر باید بتونه در میان کلمات نوشته شده دوباره تایپ کنه من در نوشتنش مشکل دارم میشه بهم کمک کنید.