حورية الجنة Posted ابريل 22, 2007 Report Share Posted ابريل 22, 2007 بسم الله الرحمن الرحيم هلا شخباركم بغيت منكم اساعدوني وشوفوا لي شنو الخطا اللي سويته مو عارفة بالضبط تعبت وانا احاول فيه هذا السؤال Suppose that m and n are integers and m is nonzero. Recall that m is called a divisor of n if n = mt for some integer t; that is, when m divides n, the reminder is 0. Moreover, m is called a proper devisor of n if m < n and m divides n. A positive integer is called perfect if it is the sum of its positive proper devisors. For example, the positive proper devisors of 28 are 1, 2, 4, 7 and 14 and 1+ 2 + 4 + 7 + 14 = 28, therefore, 28 is perfect. Write a program that takes as input a positive integer and then outputs whether the integer is perfect. وهذا اللي كتبته #include <iostream> using namespace std; int main() { int m,n,t,sum; cin>>n; cout<<"the positive proper devisors of:"<<endl; cout<<"are"<<endl; for(m=1;m=n-1;m++) n=m*t; m<n; n%=m; m=0; cout<<n<<endl; n=sum; cout<<"perfect"<<endl; return 0; } مشكورين مقدما Quote Link to comment Share on other sites More sharing options...
صدى الآهات Posted ابريل 22, 2007 Report Share Posted ابريل 22, 2007 ممكن خيتو تقولين لي وين الخطأ يطلع لج؟؟ انا البرنامج امسح من كمبيوتر Quote Link to comment Share on other sites More sharing options...
حورية الجنة Posted ابريل 22, 2007 Author Report Share Posted ابريل 22, 2007 ابي يطلع لي العوامل وابي اجمعهم بس ما يصير لي ومشكورة خيتو على الرد Quote Link to comment Share on other sites More sharing options...
Blue rose Posted ابريل 22, 2007 Report Share Posted ابريل 22, 2007 (edited) أول شيء المفروض تسوين if statement ان يكون m<n و m%n وبعدين تخلين العمليات .. وبالنسبة إلى forloop لازم اقواس لأن أكثر من شيء بتسويه الـfor .. بعد في شيء في السؤال m divides n بس انتي في البرنامج مسوية العكس .. هالاشياء بغض النظر إذا كان البرنامج بيطلع لج الجواب الصح أو لاء بس الأخطاء اللي جفتها قلتها لج عقب ماتعدلين هاي كامل بعدين بنجوف العمليات عشان يطلع لج البرنامج العوامل ويجمعهم Blue rose Edited ابريل 22, 2007 by Blue rose Quote Link to comment Share on other sites More sharing options...
حورية الجنة Posted ابريل 24, 2007 Author Report Share Posted ابريل 24, 2007 مشكووووووووووووووورة أختي روز يعطيج الله ألف عافية يا رب قعدت أحاول في أني أحله بس ما عرفت سويت اللي قلتي عليه بس ما عرفت وهذا اللي سويته شوفيلي وين الخطا #include <iostream> using namespace std; int main() { int m,n,t; cin>>n; cout<<"the positive proper devisors of:"<<endl; cout<<"are"<<endl; if(m%n==0 && m<n) { m/n; for(m=1;m>=1;m++) t=3; n=m*t; cout<<n<<endl; } cout<<"perfect"<<endl; return 0; } تحياتي Quote Link to comment Share on other sites More sharing options...
صدى الآهات Posted ابريل 25, 2007 Report Share Posted ابريل 25, 2007 لا حظت عندج غلط انتي كاتبه int m,n,t; المفروض تكتبين int m;n;t; Quote Link to comment Share on other sites More sharing options...
TheBaDBoY Posted ابريل 25, 2007 Report Share Posted ابريل 25, 2007 (edited) تبين الحل ولا تبين تعرفين شنو الغلط؟ أنا ما عندي ++C هالفصل بس حاولت أحله وصار أوكي #include <iostream.h> int main () { int m, n, temp, sum = 0; cout << "Enter a positive integer: "; cin >> n; for (m = 1; m < n; m++) { temp = n % m; if (temp == 0) sum += m; } if (sum == n) cout << "The integer you entered is perfect.\n"; else cout << "The integer you entered is not perfect.\n"; return 0; } Edited ابريل 25, 2007 by TheBaDBoY Quote Link to comment Share on other sites More sharing options...
حورية الجنة Posted ابريل 25, 2007 Author Report Share Posted ابريل 25, 2007 مشكوووووووورين يعطيكم العافية يارب انا طرشت الاسايمنت للاستاذة مشكووووورين مرة ثانية تحياتي Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.