public static void putTriangle(int width,char type,intshape){switch(shape){case 1://直角三角形,直角在左上
for(int i = 0;i
System.out.print(type);
}
System.out.print('\n');
}break;case 2://直角三角形,直角在右上
for(int i = 0;i
System.out.print(' ');
}for(int j = 0;j
System.out.print(type);
}
System.out.print('\n');
}break;case 3://直角三角形,直角在右下
for(int i = 0;i
System.out.print(' ');
}for(int j = 0;j<=i;j++){
System.out.print(type);
}
System.out.print('\n');
}break;case 4://直角三角形,直角在左下
for(int i = 0;i
System.out.print(type);
}
System.out.print('\n');
}break;case 5://等腰三角形,朝上
width = width%2!=0?width:width+1;for(int i = 0;i
System.out.print(' ');
}for(int j = 0;j
System.out.print(type);
}
System.out.print('\n');
}break;case 6://等腰三角形,朝右
width = width%2!=0?width:width+1;for(int i = 0;i<=width;i++){for(int j = 0;j<=(width+1)/2 - Math.abs(i-(width+1)/2);j++){
System.out.print(type);
}
System.out.print('\n');
}break;case 7://等腰三角形,朝下
width = width%2!=0?width:width+1;for(int i = 0;i<=(width+1)/2;i++){for(int j = 0;j
System.out.print(' ');
}for(int j = 0;j
System.out.print(type);
}
System.out.print('\n');
}break;case 8://等腰三角形,朝左
width = width%2!=0?width:width+1;for(int i = 0;i
System.out.print(' ');
}for(int j = 0;j
System.out.print('$');
}
System.out.print('\n');
}break;
}