How to reverse a string using a recursive function, without
swapping or using an extra memory?
Answer Posted / osama al-ahmad
#include <iostream>
#include < string >
using namespace std;
int i=0;
int z=0;
int count=0;
int Length(string name)
{
if (name[i] == '\0')
return count;
else
{
count++;
i++;
return Length(name);
}
}
char Print_B(string name)
{
if (z == Length(name))
return name[z];
else
{
z++;
cout<<name[count];
count--;
return Print_B(name);
}
}
void main()
{
string name;
cin>>name;
cout<<"Name : ";
Length(name);
cout<<Print_B(name);
}
Is This Answer Correct ? | 4 Yes | 3 No |
Post New Answer View All Answers
Write a C program linear.c that creates a sequence of
processes with a given length. By
sequence it is meant that each created process has exactly
one child.
Let's look at some example outputs for the program.
Here the entire process sequence consists of process 18181:
Sara@dell:~/OSSS$ ./linear 1
Creating process sequence of length 1.
18181 begins the sequence.
An example for a sequence of length three:
Sara@dell:~/OSSS$ ./linear 3
Creating process sequence of length 3.
18233 begins the sequence.
18234 is child of 18233
18235 is child of 18234
........ this is coad .... BUt i could not compleate it .....:(
#include
void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }
What are the features of c language?
how to build a exercise findig min number of e heap with list imlemented?
What is the use of typedef in structure in c?
What language is c written?
difference between object file and executable file
What is variable and explain rules to declare variable in c?
A c program to display count values from 0 to 100 and flash each digit for a secong.reset the counter after it reaches 100.use for loop,. pls guys hepl me.. :(
What is mean by data types in c?
What language is windows 1.0 written?
pierrot's divisor program using c or c++ code
In cryptography, you could often break the algorithm if you know what was the original (plain) text that was encoded into the current ciphertext. This is called the plain text attack. In this simple problem, we illustrate the plain text attack on a simple substitution cipher encryption, where you know each letter has been substituted with a different letter from the alphabet but you don’t know what that letter is. You are given the cipherText as the input string to the function getwordSets(). You know that a plain text "AMMUNITION" occurs somewhere in this cipher text. Now, you have to find out which sets of characters corresponds to the encrypted form of the "AMMUNITION". You can assume that the encryption follows simple substitution only. [Hint: You could use the pattern in the "AMMUNITION" like MM occurring twice together to identify this]
What are variables c?
What is a wrapper function in c?