消消乐 import java.util.Scanner; publicclass Main { int[][] map =newint[ 10 ][ 10 ]; publicstaticvoid main ( String [] args ) { Main main = new Main () ; main. init () ; } void init () { buildMap() ; // print(); Scanner scanner = new Scanner ( System .in) ; while (scanner. hasNext ()) { touch( scanner .nextInt()) ; } } privatevoid touch (int tar ) { int i, j; if ( tar == 100 ) { i = 9 ; j = 9 ; } elseif ( tar == 1 ) { i = 0 ; j = 0 ; } else { j = ( tar - 1 ) % 10 ; i = ( tar - 1 ) / 10 ; } if (map[i][j] != - 1 ) { touch (i, j) ; } zhegnli() ; // printMap(); print() ; } privatevoid printMap () { for ( int i = 0 ; i < 10 ; i++ ) { StringBuffer sb = new StringBuffer () ; for ( int j = 0 ; j < 10 ; j++ ) { sb. append (map[i][j] + "  " ) ; } System . out .println( sb .toString()) ; } System . out .println() ; } privatevoid print () { int red = 0 , green = 0 , blue = 0 , yellow = 0 , puple = 0 ; for ( int i = 0 ; i < 10 ; i++ ) { for ( int j = 0 ; j < 10 ; j++ ) { int now = map[i][j] ; if (now == 0 ) red++; else if (now == 1 ) green++; else if (now == 2 ) blue++; else if (now == 3 ) yellow++; else if (now == 4 ) puple++; } } System .out. println (red + " " + green + " " + blue + " " + yellow + " " + puple) ; } privatevoid zhegnli () { for ( int i = 0 ; i < 10 ; ) { if (shuIsNull( i )) { moveLeft( i ) ; } else { i++; } } for ( int j = 0 ; j < 10 ; j++ ) { int pos = 9 ; for ( int i = 9 ; i >= 0 ; i-- ) { if (map[i][j] != - 1 ) { map[pos-- ][j] = map[i][j] ; } else { // System.out.println("change " + i + "," + pos); } } for ( int i = pos; i >= 0 ; i-- ) { map[i][j] = - 1 ; } } } privatevoid moveLeft (int pos ) { for ( int i = pos + 1 ; i < 10 ; i++ ) { for ( int j = 0 ; j < 10 ; j++ ) { map[j][i - 1 ] = map[j][i] ; map[j][i] = - 1 ; } } } privateboolean shuIsNull (int pos ) { for ( int i = 0 ; i < 10 ; i++ ) { if (map[i][ pos ] != - 1 ) returnfalse; } returntrue; } privatevoid touch (int i,int j ) { // System.out.println("touch "+i+","+j); deal ( i , j , map[ i ][ j ]) ; } privatevoid deal (int i,int j,int tar ) { if ( in ( i , j ) && map[ i ][ j ] == tar ) { map[ i ][ j ] = - 1 ; deal ( i + 1 , j , tar ) ; deal ( i - 1 , j , tar ) ; deal ( i , j + 1 , tar ) ; deal ( i , j - 1 , tar ) ; } } privateboolean in (int i,int j ) { if ( i >= 0 && i < 10 && j >= 0 && j < 10 ) returntrue; else returnfalse; } privatevoid buildMap () { String [] strs = { "RED,RED,BLUE,BLUE,GREEN,YELLOW,BLUE,YELLOW,RED,PURPLE", "GREEN,GREEN,GREEN,BLUE,RED,PURPLE,RED,YELLOW,YELLOW,BLUE", "BLUE,RED,RED,YELLOW,YELLOW,PURPLE,BLUE,GREEN,GREEN,BLUE", "YELLOW,RED,BLUE,YELLOW,BLUE,RED,PURPLE,GREEN,GREEN,RED", "YELLOW,RED,BLUE,BLUE,PURPLE,GREEN,PURPLE,RED,YELLOW,BLUE", "PURPLE,YELLOW,RED,RED,YELLOW,RED,PURPLE,YELLOW,RED,RED", "YELLOW,YELLOW,GREEN,PURPLE,GREEN,RED,BLUE,YELLOW,BLUE,GREEN", "RED,YELLOW,BLUE,BLUE,YELLOW,GREEN,PURPLE,RED,BLUE,GREEN", "GREEN,GREEN,YELLOW,YELLOW,RED,RED,PURPLE,BLUE,BLUE,GREEN", "PURPLE,BLUE,RED,RED,PURPLE,YELLOW,BLUE,RED,RED,GREEN" } ; for ( int i = 0 ; i < 10 ; i++ ) { String [] curs = strs[i] . split ( "," ) ; for ( int j = 0 ; j < 10 ; j++ ) { String str = curs[j] ; int tar = - 1 ; if (str. equals ( "RED" )) tar = 0 ; else if (str. equals ( "GREEN" )) tar = 1 ; else if (str. equals ( "BLUE" )) tar = 2 ; else if (str. equals ( "YELLOW" )) tar = 3 ; else if (str. equals ( "PURPLE" )) tar = 4 ; map[i][j] = tar; } } } }
点赞 6

相关推荐

就前几天旅游的时候,打开抖音就经常刷到这类视频:以前是高学历学生、老师、主持人,现在做着团播、擦边主播的工作,以及那些经过精心包装的“职业转型”故事——从铺天盖地的VLOG到所谓的“04年夜场工作日记”,这些内容在初中升学、高考放榜等关键时间节点持续发酵。可以说非常直接且精准地在潜移默化地影响着心智尚未成熟的青少年,使其对特殊行业逐渐脱敏。那我就想问了:某些传播公司、平台运营者甚至某些夜场的老板,你们究竟在传递怎样的价值观?点开那些视频,评论区里也是呈现明显的两极分化:一种是​​经济下行论​​:“现在就业市场已经艰难到这种程度了吗?”​​一种是事实反驳派​​:这些创作者往往拥有名校背景,从事着...
牛客刘北:被环境教育的,为了能拿到足够的钱养活自己,不甘心也得甘心,现在的短视频传播的思想的确很扭曲,但是很明显,互联网玩上一年你就能全款提A6,但你全心全意不吃不喝工作一年未必能提A6,但是在高考中考出现这个的确很扭曲,在向大家传播“不上学,玩互联网也可以轻松年入百万”,不是人变了,是社会在变
预测一下26届秋招形势
点赞 评论 收藏
分享
今天 12:20
门头沟学院 运营
点赞 评论 收藏
分享
06-15 02:05
已编辑
南昌航空大学 数据分析师
Eason三木:你如果想干技术岗,那几个发公众号合唱比赛的经历就去掉,优秀团员去掉,求职没用。然后CET4这种不是奖项,是技能,放到下面的专业技能里或者单独列一个英语能力。 另外好好改改你的排版,首行缩进完全没有必要,行间距好好调调,别让字和标题背景黏在一起,你下面说能做高质量PPT你得展现出来啊,你这简历排版我用PPT做的都能比你做的好。 然后自我评价,你如果要干数据工程师,抗压能力强最起码得有吧。
简历中的项目经历要怎么写
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务