This problem is writing a complete program that will correctly decode a set of characters into a valid message. It should read a given file of a simple coded set of characters and print the exact message that the characters contain. The code key for this simple coding is a one for one character substitution based upon a single arithmetic manipulation of the printable portion of the ASCII character set. For the complete information The Decode Problem
Here is soulution with java code
import java.util.Scanner;
class Decode{
public static void main(String args[]){
Scanner s=new Scanner(System.in);
char c;
String kal;
while((s.hasNext())){
kal=s.nextLine();
if(kal.isEmpty()==false){
for(int i=0;i<kal.length();i++){
c=(char) (kal.charAt(i)-7);
System.out.print(c);
}
System.out.println();
}else break;
}
}
}
Here is ansi c code
#include <stdio.h>
main() {
char *str;
char c;
int i;
while(scanf("%s",str)!=EOF){
for(i=0;i<str[i]!='\0';i++){
c=str[i]-7;
printf("%c",c);
}
printf("\n");
}
}
Here is c++ code
#include <iostream>
using namespace std;
int main() {
char str[255];
char c;
while(cin>>str){
for(int i=0;str[i]!='\0';i++){
c=str[i]-7;
cout<<c;
}
cout<<endl;
}
return 0;
}