int i = 10;
while(i) {
cout << i << " ";
i--;
}
Rot13 is a simple
Caesar's cypher that given a string replaces each letter with the
letter 13 later in the alphabet(wraping around when you get to the
end). More, formally: if c is the position of a letter in the
alphabet (not the ascii or unicode value), ROT13(c) = (c+13)%26. You
have to convert from unicode to the position value before apploying
that function, and convert back to get the new character. This may
require consideration of the distinction between upper and lower case
in unicode. A nice property of ROT13 is that when you run it twice,
you get back to the original text.
Write a program that reads a line of text, performs ROT13 on it and prints the result. Non-letter characters should not be changed, and capitalization should be preserved, e.g. A → N and a → n. Show this to your instructor.
Things you need to know:
String s;
...
char c = s.charAt(0);//returns the first character
String s;
...
for(int i = 0 i < s.length(); i++){
System.out.print(s.charAt(i));
}
int anIntArray[];
boolean aBoolArray[] = new boolean[10];
String[] aStringArray = { "array", "of", "String" };
Some things to note:
int[] ia = new int[101];
for (int i = 0; i < ia.length; i++)
ia[i] = i;
int sum = 0;
for (int i = 0; i < ia.length; i++)
sum += ia[i];
System.out.println(sum);
Things you need to know:
String s,t;
...
if(s.compareTo(t) < 0) ...
s.compareTo(t) is less than 0 if s comes before t, equal to 0 if
they are the same, and is greater than 0 if s comes after t.