وردة النرجس
Well-Known Member
- تاريخ التسجيل
- 30 يناير 2010
- المشاركات
- 72
- المجموعة
- أنثى
- الدفعة الدراسية
- 2009
- الكلية
- كلية تقنية المعلومات
- التخصص
- نظم معلومات إدارية
Write a recursive function named Rightdigit. The prototype of the function is:
int Rightdigit(int n, int k);
This function returns the kth digit of the positive integer n.
For example, if n is the integer 29815:
The call Rightdigit (n,0 ) would return the digit 5
The call Rightdigit (n,2)would return the digit 8.
Note that the digits are numbered from right to left beginning with the “zeroth digit.”
الحل
PHP:int Rightdigit(int n, int k) { if(k==0) return (n%10); else { n=(n/10); return Rightdigit(n,k-1); } }
ما فهمت السؤال
شلون سوينا جدي