***** ***** * *
**** **** ** **
*** *** *** ***
** ** **** ****
* * ***** *****
(1) (2) (3) (4)
**** **** ** **
*** *** *** ***
** ** **** ****
* * ***** *****
(1) (2) (3) (4)
解决方案 »
- 100分 求 RTS IDE
- 请教一个菜鸟优化题,谢谢
- 有关properties中的替换的问题,求教大虾们了!!
- 如何去掉字符串中的某些字符?急!
- 对DES有研究的兄弟,帮我看看我的DES加密后出来怎么会是128位长度的?
- 一个关于Observable的代码,求助
- scjp求助,这道题应该选什么,以及原因,谢谢
- File MyDir = new File("C:\soft\Adodb\");这么写不对吗?
- 有jtree访问数据库的例子吗?急!谢谢!
- 大家帮看看这段代码,给解释一下
- 请教一个关于垃圾回收的问题
- 为什么 用gb2312写入英文字符“abcdef”用utf-8能够正确读出来?写入中文就读不出来了。原理是什么?
System.out.println("*****");
System.out.println("****");
System.out.println("***");
System.out.println("**");
System.out.println("*");写个for循环 i控制行 j控制列
for(int i=5;i>0;i++){
for(int j=10;j>0;j++){
if(j>i){
System.out.println();
continue outer;
}
System.out.print("*");
}
}没有编译,不知道行不行?
是i--
和j--de
{
int num, i, j;
printf("enter a number: ");
scanf("%d", &num);
for(i = 0; i < num; i++){
for(j = 0; j <= i; j++){
printf("*");
}
printf("\n");
}
getch();
return 0;
}#include<stdio.h>int main(void)
{
int num, i, j;
printf("enter a number: ");
scanf("%d", &num);
for(i = 0; i < num; i++){
for(j = 0; j < num - i; j++){
printf("*");
}
printf("\n");
}
getch();
return 0;
}
#include<stdio.h>int main(void)
{
int num, i, j, k;
printf("enter a number: ");
scanf("%d", &num);
for(i = 0; i < num; i++){
for(k = 0; k < num - i - 1; k++){
printf(" ");
}
for(j = 0; j <= i; j++){
printf("*");
}
printf("\n");
}
getch();
return 0;
}
#include<stdio.h>int main(void)
{
int num, i, j, k;
printf("enter a number: ");
scanf("%d", &num);
for(i = 0; i < num; i++){
for(k = 0; k < i; k++){
printf(" ");
}
for(j = 0; j < num - i; j++){
printf("*");
}
printf("\n");
}
getch();
return 0;
}直角三角型四个方向的C语言实现,楼主自己改成java吧
应该是非常简单的
public class Tuxing{
public static void main(String []args){
for(int i=0;i<=4;i++)//控制行数
{
for(int j=4-i;j>=0;j--)//控制打出的"*"数
System.out.print("* ");
System.out.println();
}
}
}
后面的3个就自己写吧!多想想就会了,lz加油!
public static void main(String[] args) {
fun1(5);
fun2(5);
fun3(5);
fun4(5);
}
public static void fun1(int n) {
StringBuffer sb = new StringBuffer();
for(int i=0; i<n; i++) {
sb.append('*');
}
System.out.println(sb);
for(int j=1; j<n; j++) {
System.out.println(sb.deleteCharAt(n-j));
}
}
public static void fun2(int n) {
StringBuffer sb = new StringBuffer();
for(int j=0; j<n; j++) {
sb.append('*');
System.out.println(sb);
}
}
public static void fun3(int n) {
StringBuffer sb = new StringBuffer();
for(int i=0; i<n+n/2; i++) {
sb.append(' ');
}
for(int i=0; i<n; i++ ) {
if(i%2==1)
sb.deleteCharAt(0);
sb.deleteCharAt(0);
sb.append('*');
System.out.println(sb);
}
}
public static void fun4(int n) {
StringBuffer sb = new StringBuffer();
for(int j=0; j<n/2; j++) {
sb.append(' ');
}
sb.append('*');
System.out.println(sb);
for(int j=1; j<n; j++) {
sb.append('*');
if(j%2==1) {
sb.deleteCharAt(0);
}
System.out.println(sb);
}
}
}*****
****
***
**
*
*
**
***
****
*****
*
**
***
****
*****
*
**
***
****
*****
printRightAngledTriangle(4, Direction.RIGHT_TOP); System.out.println(Direction.RIGHT_BOTTOM);
printRightAngledTriangle(4, Direction.RIGHT_BOTTOM); System.out.println(Direction.LEFT_TOP);
printRightAngledTriangle(4, Direction.LEFT_TOP); System.out.println(Direction.LEFT_BOTTOM);
printRightAngledTriangle(4, Direction.LEFT_BOTTOM);
} public static void printRightAngledTriangle(int line, Direction mode) {
if(line < 0) {
return;
}
int istart = mode.isTop() ? -line : 1;
int iend = istart < 1 ? -1 : line;
int jstart = mode.isRight() ? -line : 1; for(int i = istart; i <= iend; i++) {
int jend = jstart < 1 ? Math.abs(i) - line - 1: line;
for(int j = jstart; j <= jend; j++) {
System.out.print(Math.abs(i) + Math.abs(j) > line ? '*' : ' ');
}
System.out.println();
}
}
}enum Direction {
RIGHT_TOP(true, true),
RIGHT_BOTTOM(false, true),
LEFT_TOP(true, false),
LEFT_BOTTOM(false, false); private boolean isTop;
private boolean isRight;
Direction(boolean isTop, boolean isRight) {
this.isTop = isTop;
this.isRight = isRight;
} public boolean isTop() {
return isTop;
}
public boolean isRight() {
return isRight;
}
}RIGHT_TOP
****
***
**
*
RIGHT_BOTTOM
*
**
***
****
LEFT_TOP
****
***
**
*
LEFT_BOTTOM
*
**
***
****