Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Hello {
- public static void main(String[]args) {
- Scanner input = newScanner(System.in);
- int size = input.nextInt();
- if(size % 2 != 0){
- int point1 = size /2;
- int point2 = size /2;
- int line = 0;
- boolean reverse =false;
- for(int n=0;n<=size*size-1; n++){
- if(line>=size){
- System.out.println();
- line= 0;
- if(reverse == false){
- point1--;
- point2++;
- }else{
- point1++;
- point2--;
- }
- }
- if(line ==point1 || line == point2){
- System.out.print("+");
- }else{
- System.out.print("-");
- }
- if(point1 ==0 || point2 == size){
- reverse = true;
- }
- line++;
- }
- }else{
- System.out.println("Трябва да въведете нечетно число!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement