1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- int[] concat(int[] a, int[] b) {
- int la = length(a);
- int lb = length(b);
- int[] s = new int[la + lb];
- for(int i = 0; i < la; i++) {
- s[i] = a[i];
- }
- for(int i = 0; i < lb; i++) {
- s[i + la] = b[i];
- }
- return s;
- }
- int compare(int[] a, int[] b) {
- int l = length(a);
- if(l != length(b)) {
- return false;
- }
- for(int i = 0; i < l; i++) {
- if(a[i] != b[i]) {
- return false;
- }
- }
- return true;
- }
- void toLower(int[] s) {
- int l = length(s);
- for(int i = 0; i < l; i++) {
- int c = s[i];
- if(c >= 'A' && c <= 'Z') {
- c = c - 'A' + 'a';
- s[i] = c;
- }
- }
- }
- void main() {
- int[] msg = "Hallo User: ";
- int[] name = "Kajetan";
- int[] together = concat(msg, name);
- int[] together2 = concat(together, name);
- test(together2);
- toLower(together);
- test(together);
-
- int[] a = name;
- test(a);
- test(a == name);
-
- int[] baum = "Kajetan";
- test(name == baum);
- test(compare(name, baum));
- test(compare(name, "Kajetan"));
- test(compare(name, "Kajetaa"));
- }
|