برنامج يقوم بهذا الأمر أنظر للصورة :
http://im51.gulfup.com/rGfQ...حيث تدخل كلمة أو جملة حيث يقوم بإظهار في السطر الأول الحرف الأخير فقط من الكلمة مباشرة في مكانه الأصلي حسب ترتيب حروف تلك الكلمة و بعدها في السطر الثاني نفس الأمر و لكن مع إظهار آخر حرفين و يقوم بفعل نفس الشيئ حتى آخر حرف .
لقد قمت ببرمجته بالباسكال و الجافا مثال :
Hi I am mino From Arabia
a
ia
bia
abia
rabia
Arabia
Arabia
m Arabia
om Arabia
rom Arabia
From Arabia
From Arabia
o From Arabia
no From Arabia
ino From Arabia
mino From Arabia
mino From Arabia
m mino From Arabia
am mino From Arabia
am mino From Arabia
I am mino From Arabia
I am mino From Arabia
i I am mino From Arabia
Hi I am mino From Arabia
رجاء جربوا حله بنفسكم بدون النظر إلى الكود المصدري .
البرنامج بالباسكال :
program projectarabia;
var
i,j,k,n:integer;
t:string;
begin
writeln('entree un mot :');
readln(t);
n:=length(t);
for i:=1 to n do
begin
for j:=n downto i+1 do
begin
write(' ');
end;
for k:=i downto 0 do
write(t[n-(k-1)]);
writeln;
end;
readln;
end.
البرنامج بالجافا :
public class Mainclass {
public static void main(String[] args){
int i,j,k,n;
String t;
char ch;
System.out.println("entree un mot :");
Scanner sc=new Scanner(System.in);
t=sc.nextLine();
n=t.length();
for(i=1;i<=n;i++){
for(j=n;j>=i+1;j--){
System.out.print(" ");
}
for(k=i;k>0;k--){
ch=t.charAt(n-k);
System.out.print(ch);
}
System.out.println();
}
}
}
أتمنى رؤية طرق مختلفة عن طريقتي للحل .
<?php
echo "<pre>";
echo $string = "We Are Future Programmers."; $array = str_split($string); // spilting the string in array // loop for the lines equal the length of my string for($i=strlen($string); $i >= 0; $i--){ //loop for check every character for ($x=0; $x <= strlen($string); $x++) { // check if the character in reverse equal the line number if($x >= $i && $x < strlen($string)){ echo $array[$x]; } else{ echo " "; } } echo "";
}
?>
<?php
echo "<pre>";
echo $string = "We Are Future Programmers."; $array = str_split($string); // spilting the string in array // loop for the lines equal the length of my string for($i=strlen($string); $i >= 0; $i--){ //loop for check every character for ($x=0; $x <= strlen($string); $x++) { // check if the character in reverse equal the line number if($x >= $i && $x < strlen($string)){ echo $array[$x];
}
else{
echo " ";
}
}
echo "<br>";
}
?>
<?php
echo "<pre>";
echo $string = "We Are Future Programmers.";
$array = str_split($string); // spilting the string in array
// loop for the lines equal the length of my string
for($i=strlen($string); $i >= 0; $i--){
//loop for check every character
for ($x=0; $x <= strlen($string); $x++) {
// check if the character in reverse equal the line number
if($x >= $i && $x < strlen($string)){
echo $array[$x];
}
else{
echo " ";
}
}
echo "";
}
?>
<?php
echo "<pre>";
echo $string = "We Are Future Programmers.";
$array = str_split($string); // spilting the string in array
// loop for the lines equal the length of my string
for($i=strlen($string); $i >= 0; $i--){
//loop for check every character
for ($x=0; $x <= strlen($string); $x++) {
// check if the character in reverse equal the line number
if($x >= $i && $x < strlen($string)){
echo $array[$x];
}
else{
echo " ";
}
}
echo "<br>";
}
?>
التعليقات