Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Function by : Kadoel Noesa
- Penggunaan : Ganjil(10)
- output : 1-3+5-7+9-11+13-15+17-19
- */
- public class ganjil
- {
- public static void main (String[]args)
- {
- int x,y,z;
- y=10;
- x=y*2;
- z=1;
- if (x%2==0)
- {
- System.out.print(z); System.out.print("");
- for (y=1; y<x-1; y++)
- {
- System.out.print(" - ");
- System.out.print(y+2);
- y=y+2;
- System.out.print(" + ");
- System.out.print(y+2);
- y=y+1;
- if (y==x-4)
- {
- break;
- }
- }
- }
- System.out.print(" - ");
- System.out.print(x-1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement