2016-04-07 16 views
0
#include<iostream.h> 
#include<conio.h> 
#include<string.h> 

char text[]="A nut for a jar of tuna"; 
int txtposition,txtlength; 

void main() 
{ 
    clrscr(); 
    txtlength=Strlen(text); 

    for(txtposition=0; txtposition<=txtlength;txtposition++) 
    { 
     cout<<text[txtposition]; 
    } 
getch(); 
} 

Bu program, metin değerini ters sırada yazdırmak için nasıl yeniden yazılır?Bu programı, metin değerini ters sırayla yazdıracak şekilde nasıl yeniden yazabilirim

+1

Lütfen bize şimdiye kadar neler denediğinizi gösterin. – unicorn2

+0

'for' loop:' for (txtposition = txtlength - 1; txtposition> = 0; txtposition -) ' –

+0

Bu, C++ sorusu olarak etiketlenmemelidir. – Moreira

cevap

0
#include<iostream.h> 
#include<conio.h> 
#include<string.h> 

char text[]="A nut for a jar of tuna"; 
int txtposition,txtlength; 

void main() 
{ 
    clrscr(); 
    txtlength=Strlen(text); 

    for(txtposition= txtlength-1 ; txtposition>=0;txtposition--) 
    { 
     cout<<text[txtposition]; 
    } 
    getch(); 
} 
0

Sen @Prashant önerdiği cevapla gidebilir ya da size ters metin kaydedebilirsiniz başka char reversetext[] oluşturun. Bu sayede ihtiyaçlarınız doğrultusunda kullanabilirsiniz. Ayrıca, her sözcüğü ters çevirmeye çalışıyorsanız, farklı bir daha uzun algoritma gereklidir. Onu arıyorsan haberim olsun.

İlgili konular