package com.tree.autotest.demo;

import com.alibaba.fastjson.JSON;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Test; import java.io.*;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*; /**
* 规则包:
* 规则编码:
* 规则名称:
* 规则条件:
* <p/>
*/
public class ExcelHandle { /**
* 将时间毫秒数转换成:yyyy-MM-dd HH:mm:ss 格式的字符串
* @param longtime
* @return
*/
public static String getTimeByLongTime(long longtime){
Date dat=new Date(longtime);
GregorianCalendar gc = new GregorianCalendar();
gc.setTime(dat);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String sb=format.format(gc.getTime());
return sb;
} /**
*
* @param timeStr 类似于:Tue Mar 03 00:00:00 CST 2015 这样的时间字符串
* @return
*/
public static String getTimeByLongTime(String timeStr){
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", Locale.UK);
Date time = null;
try {
time = sdf.parse (timeStr);
} catch (ParseException e) {
e.printStackTrace();
}
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String sb=format.format(time);
return sb;
}
/**
* 通过map转成
* @param testcaselist 所有TC
* @param componentName
* @param excelIndex
* @return
*/
public static String requestJsonStrByMap(Map<String, ArrayList<String>> testcaselist,String componentName,int excelIndex){
String requestJsonStr = null;
try{
Map<String, String> paramMap= getTestCaseMap(testcaselist,excelIndex);
Map<String, Object> reqMap = new HashMap<String, Object>(); reqMap.put("name", componentName);
reqMap.put("session", paramMap);
requestJsonStr = JSON.toJSONString(reqMap, true);
}catch(Exception e){
}
return requestJsonStr;
} /**
* 通过map转成
* @param componentName
* @param excelPath
* @param excelIndex
* @return
*/
public static String requestJsonStrByMap(String excelPath,String componentName,int excelIndex){
String requestJsonStr = null;
try{
Map<String, String> paramMap= getTestCaseMap(excelPath,excelIndex); Map<String, Object> reqMap = new HashMap<String, Object>(); reqMap.put("name", componentName);
reqMap.put("session", paramMap);
requestJsonStr = JSON.toJSONString(reqMap, true);
}catch(Exception e){
}
return requestJsonStr;
} /**
* 通过字符串拼接的方式组合成json
* @param componentName
* @param excelPath
* @param excelIndex
* @return
*/
public static String requestJsonStrByStr(String excelPath,String componentName,int excelIndex){
StringBuilder sb = new StringBuilder("{\"name\":\""+componentName+"\",");
String tcJsonStr = getTestCaseJsonStr(excelPath,excelIndex);
sb.append("\"session\":");
sb.append(tcJsonStr);
return sb.append("}").toString();
} /**
* 将TC的入参以Map形式返回(不包含预期值)
* @param testcaselist 所有TC
* @param excelIndex
* @return
*/
private static Map<String, String> getTestCaseMap(Map<String, ArrayList<String>> testcaselist,int excelIndex){
try{
if(excelIndex <= 1) throw new Exception("输入的excel行号必须大于1");
ArrayList<String> clNames = testcaselist.get("1");// 列名
ArrayList<String> paramValues = new ArrayList<String>();
paramValues = testcaselist.get(excelIndex + "");
Map<String, String> paramMap= new HashMap<String, String>();
for (int i = 1; i < clNames.size(); i++) {//除去首例:用例名称
paramMap.put(clNames.get(i), paramValues.get(i));
}
paramMap.remove("预期值");//除去最后一列:预期值
paramMap.remove("实际值");//除去最后一列:实际值
return paramMap;
}catch(Exception e){
return null;
}
} /**
* 将TC的入参以Map形式返回(不包含预期值)
* @param excelPath
* @param excelIndex
* @return
*/
private static Map<String, String> getTestCaseMap(String excelPath,int excelIndex){
try{
if(excelIndex <= 1) throw new Exception("输入的excel行号必须大于1");
Map<String, ArrayList<String>> testcaselist = ReadXlsx_2(excelPath);
ArrayList<String> clNames = testcaselist.get("1");// 列名
ArrayList<String> paramValues = new ArrayList<String>();
paramValues = testcaselist.get(excelIndex + "");
Map<String, String> paramMap= new HashMap<String, String>();
for (int i = 1; i < clNames.size(); i++) {//除去首例:用例名称
paramMap.put(clNames.get(i), paramValues.get(i));
}
paramMap.remove("预期值");//除去最后一列:预期值
return paramMap;
}catch(Exception e){
return null;
}
}
/**
* 将TC的入参以JsonStr形式返回(不包含预期值)
* @param excelPath excelpath文件路径
* @param excelIndex excel行号 PS:要大于1,因为1是列名
* @return
*/
public static String getTestCaseJsonStr(String excelPath,int excelIndex){
String jsonText = null;
try {
Map<String, String> paramMap= getTestCaseMap(excelPath, excelIndex);
jsonText = JSON.toJSONString(paramMap, true);
} catch (Exception e) {
e.printStackTrace();
}
return jsonText;
} /**
* 获取某个TC的预期值,默认预期值的列名是:预期值
* @param testcaselist 所有TC
* @param excelIndex
* @return
*/
public static String getExpectedValue(Map<String, ArrayList<String>> testcaselist,int excelIndex){
String expectedValue = null;
try {
if(excelIndex <= 1) throw new Exception("输入的excel行号必须大于1");
ArrayList<String> clNames = testcaselist.get("1");// 列名
ArrayList<String> paramValues = new ArrayList<String>();
paramValues = testcaselist.get(excelIndex + "");
Map<String, String> paramMap= new HashMap<String, String>();
for (int i = 1; i < clNames.size(); i++) {//除去用例名称
paramMap.put(clNames.get(i), paramValues.get(i));
}
expectedValue = paramMap.get("预期值");
} catch (Exception e) {
e.printStackTrace();
}
return expectedValue;
} /**
* 获取某个TC的预期值,默认预期值的列名是:预期值
* @param excelPath
* @param excelIndex
* @return
*/
public static String getExpectedValue(String excelPath,int excelIndex){
String expectedValue = null;
try {
if(excelIndex <= 1) throw new Exception("输入的excel行号必须大于1");
Map<String, ArrayList<String>> testcaselist = ReadXlsx_2(excelPath);
ArrayList<String> clNames = testcaselist.get("1");// 列名
ArrayList<String> paramValues = new ArrayList<String>();
paramValues = testcaselist.get(excelIndex + "");
Map<String, String> paramMap= new HashMap<String, String>();
for (int i = 1; i < clNames.size(); i++) {//除去用例名称
paramMap.put(clNames.get(i), paramValues.get(i));
}
expectedValue = paramMap.get("预期值");
} catch (Exception e) {
e.printStackTrace();
}
return expectedValue;
}
/**
* 获取某个TC的预期值,默认预期值的列名是:预期值
* @param excelPath
* @param excelIndex
* @param expectedValueColName 预期值的列名
* @return
*/
public static String getExpectedValue(String excelPath,int excelIndex,String expectedValueColName){
String expectedValue = null;
try {
if(excelIndex <= 1) throw new Exception("输入的excel行号必须大于1");
Map<String, ArrayList<String>> testcaselist = ReadXlsx_2(excelPath);
ArrayList<String> clNames = testcaselist.get("1");// 列名
ArrayList<String> paramValues = new ArrayList<String>();
paramValues = testcaselist.get(excelIndex + "");
Map<String, String> paramMap= new HashMap<String, String>();
for (int i = 1; i < clNames.size(); i++) {//除去用例名称
paramMap.put(clNames.get(i), paramValues.get(i));
}
expectedValue = paramMap.get(expectedValueColName);
} catch (Exception e) {
e.printStackTrace();
}
return expectedValue;
} /**
* 获取第一个Sheet
*
* @param filePath
* @return
*/
private static XSSFSheet getSheet(String filePath) {
File file = new File(filePath);
XSSFSheet xssfSheet = null;
try {
OPCPackage opcPackage = OPCPackage.open(file);
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(opcPackage);
xssfSheet = xssfWorkbook.getSheetAt(0);
} catch (Exception e) {
e.printStackTrace();
}
return xssfSheet;
} /**
* 获每列的列名(即sheet的第一列)
*
* @param xssfSheet
* @return
*/
private static ArrayList<String> getColumnName(XSSFSheet xssfSheet) {
XSSFRow row_1 = xssfSheet.getRow(0);
ArrayList<String> colsName = new ArrayList<String>();
int lieNum = row_1.getPhysicalNumberOfCells(); for (int t = 0; t < lieNum; t++) {
colsName.add(row_1.getCell(t).getStringCellValue());
}
return colsName;
} /**
* 读取测试用例excel文件,将所有的case保存在map中,以行号为key,从1开始包括第一行
* @param filePath
* @return
* @throws InvalidFormatException
* @throws IOException
*/
public static Map<String, ArrayList<String>> ReadXlsx_2(String filePath)
throws InvalidFormatException, IOException {
// XSSFSheet xssfSheet = getSheet(filePath);
//
// int totalRows = xssfSheet.getPhysicalNumberOfRows();// 得到总行数
// int rowstart = xssfSheet.getFirstRowNum();
// int rowEnd = xssfSheet.getLastRowNum();
// ////////////// 获取每列名称//////////////
// ArrayList<String> lieName = getColumnName(xssfSheet);
// int lieNum = lieName.size();
// ////////////////////////////
// Map<String, ArrayList<String>> testcaselist = new HashMap<String, ArrayList<String>>();
// for (int i = rowstart; i <= rowEnd; i++)// 获取每一行即一个TC(包括第一行)
// {
// XSSFRow row = xssfSheet.getRow(i);
// if (null == row)
// continue;
// ArrayList<String> paramValues = new ArrayList<String>();
// for (int t = 0; t < lieNum; t++) { // 获取每一列的值
//// String cellValue = "";
//// try {
//// cellValue = row.getCell(t).getStringCellValue();
//// } catch (Exception e) {
//// if ("Cannot get a text value from a numeric cell".equals(e.getMessage())) {
//// cellValue = (int)row.getCell(t).getNumericCellValue() + "";
//// }
//// }
//// paramValues.add(cellValue);
//
// String cellValue = "";
// XSSFCell cell = row.getCell(t);
// if (null == cell){
// paramValues.add("");
// continue;
// }
// switch (cell.getCellType()) {
// case HSSFCell.CELL_TYPE_NUMERIC: // 数字
//
// if (HSSFDateUtil.isCellDateFormatted(cell)) {
// long longtime = Math.round(cell.getNumericCellValue());
// cellValue = getTimeByLongTime(longtime);//将时间毫秒数转换成:yyyy-MM-dd HH:mm:ss 格式的字符串
// } else {
// double tempValue = cell.getNumericCellValue();
// long longVal = Math.round(tempValue);
// if (Double.parseDouble(longVal + ".0") == tempValue)
// cellValue = longVal + ""; //整数
// else
// cellValue = tempValue + "";//小数
// }
// paramValues.add(cellValue);
// break;
// case HSSFCell.CELL_TYPE_STRING: // 字符串
// cellValue = cell.getStringCellValue();
// paramValues.add(cellValue);
// break;
// case HSSFCell.CELL_TYPE_BOOLEAN: // Boolean
// cellValue = cell.getBooleanCellValue()+"";
// paramValues.add(cellValue);
// break;
// case HSSFCell.CELL_TYPE_FORMULA: // 公式
// cellValue = cell.getCellFormula()+"";
// paramValues.add(cellValue);
// break;
// case HSSFCell.CELL_TYPE_BLANK: // 空值
// cellValue = cell.getCellFormula()+"";
// paramValues.add(cellValue);
// break;
// case HSSFCell.CELL_TYPE_ERROR: // 故障
// cellValue = "";
// paramValues.add(cellValue);
// break;
// default:
// System.out.print("未知类型 ");
// cellValue = "";
// paramValues.add(cellValue);
// break;
// }// switch结束
// }
// String key = (i + 1) + "";// 以行号为key,从0开始
// testcaselist.put(key, paramValues);
// }
// return testcaselist; Map<String, ArrayList<String>> testcaselist = new HashMap<String, ArrayList<String>>();
File file = new File(filePath);
try {
OPCPackage opcPackage = OPCPackage.open(file);
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(opcPackage);
testcaselist = ReadXlsx_2(xssfWorkbook);
} catch (Exception e) {
e.printStackTrace();
}
return testcaselist;
} /**
* 读取测试用例excel文件,将所有的case保存在map中,以行号为key,从1开始包括第一行
* @param wb excel工作簿
* @return
* @throws InvalidFormatException
* @throws IOException
*/
public static Map<String, ArrayList<String>> ReadXlsx_2(XSSFWorkbook wb)
throws InvalidFormatException, IOException {
XSSFSheet xssfSheet = wb.getSheetAt(0);//getSheet(filePath); int totalRows = xssfSheet.getPhysicalNumberOfRows();// 得到总行数
int rowstart = xssfSheet.getFirstRowNum();
int rowEnd = xssfSheet.getLastRowNum();
////////////// 获取每列名称//////////////
ArrayList<String> lieName = getColumnName(xssfSheet);
int lieNum = lieName.size();
////////////////////////////
Map<String, ArrayList<String>> testcaselist = new HashMap<String, ArrayList<String>>();
for (int i = rowstart; i <= rowEnd; i++)// 获取每一行即一个TC(包括第一行)
{
XSSFRow row = xssfSheet.getRow(i);
if (null == row)
continue;
ArrayList<String> paramValues = new ArrayList<String>();
for (int t = 0; t < lieNum; t++) { // 获取每一列的值
// String cellValue = "";
// try {
// cellValue = row.getCell(t).getStringCellValue();
// } catch (Exception e) {
// if ("Cannot get a text value from a numeric cell".equals(e.getMessage())) {
// cellValue = (int)row.getCell(t).getNumericCellValue() + "";
// }
// }
// paramValues.add(cellValue); String cellValue = "";
XSSFCell cell = row.getCell(t);
if (null == cell){
paramValues.add("");
continue;
}
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_NUMERIC: // 数字 if (HSSFDateUtil.isCellDateFormatted(cell)) { String timeStr =cell.getDateCellValue().toString(); long longtime = Math.round(cell.getNumericCellValue());
cellValue = getTimeByLongTime(timeStr);//将时间毫秒数转换成:yyyy-MM-dd HH:mm:ss 格式的字符串
} else {
double tempValue = cell.getNumericCellValue();
long longVal = Math.round(tempValue);
if (Double.parseDouble(longVal + ".0") == tempValue)
cellValue = longVal + ""; //整数
else
cellValue = tempValue + "";//小数
}
paramValues.add(cellValue);
break;
case HSSFCell.CELL_TYPE_STRING: // 字符串
cellValue = cell.getStringCellValue();
paramValues.add(cellValue);
break;
case HSSFCell.CELL_TYPE_BOOLEAN: // Boolean
cellValue = cell.getBooleanCellValue()+"";
paramValues.add(cellValue);
break;
case HSSFCell.CELL_TYPE_FORMULA: // 公式
cellValue = cell.getCellFormula()+"";
paramValues.add(cellValue);
break;
case HSSFCell.CELL_TYPE_BLANK: // 空值
// cellValue = cell.getCellFormula()+"";
cell.setCellValue("");
// cellValue = cell.getCellFormula()+"";
paramValues.add("");
break;
case HSSFCell.CELL_TYPE_ERROR: // 故障
cellValue = "";
paramValues.add(cellValue);
break;
default:
System.out.print("未知类型 ");
cellValue = "";
paramValues.add(cellValue);
break;
}// switch结束
}
String key = (i + 1) + "";// 以行号为key,从0开始
testcaselist.put(key, paramValues);
}
return testcaselist;
} public static InputStream loadExcel(String filePath){
InputStream myxlsx = null;
try {
myxlsx = new FileInputStream(filePath);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return myxlsx;
} public static XSSFWorkbook getWorkBook(String myxlsName){
XSSFWorkbook wb = null;
try {
wb = new XSSFWorkbook(loadExcel(myxlsName));
} catch (IOException e) {
e.printStackTrace();
}
return wb;
} /**
* 修改指定单元格的内容
* @param myxls 以流的形式,先读excel的内容
* @param rowNum 单元格的行号,从0开始
* @param colNum 单元格的列号,从0开始
* @param cellContext 向指定单元格写入的内容
* @return
*/
public static boolean writeExcel(String myxls,int rowNum,int colNum,String cellContext){
XSSFWorkbook wb = getWorkBook(myxls);
XSSFSheet xssfSheet = null;
if(xssfSheet == null) xssfSheet = wb.getSheetAt(0);
try {
XSSFRow row = xssfSheet.getRow(rowNum);
if(row == null) throw new Exception("该sheet中不存在"+rowNum+"行");
XSSFCell cell = row.getCell(colNum);
if(cell == null) cell = row.createCell(colNum);//throw new Exception("该sheet中不存在"+rowNum+"行,"+colNum+"列");
cell.setCellValue("");
cell.setCellValue(cellContext);
FileOutputStream fileOut = null;
try{
fileOut = new FileOutputStream(myxls);
wb.write(fileOut);
}finally {
try {
fileOut.close();
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}
/*
++++++++++++++++++++++++++++++++++++++++++++数据驱动模块相关+++++++++++++++++++++++++++++++
*/
/**
* TestNG 参数化方法,
* @param fileName excel文件路径
* @param sheetName sheet名称
* @return:返回二维数组对象,HashMap类型,列名(参数名称)为Key值,每行参数值为value。
*/ public static Object[][] readXlsx(String fileName, String sheetName) throws IOException {
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(fileName);
XSSFSheet xssfSheet = xssfWorkbook.getSheet(sheetName); int totalRow = xssfSheet.getLastRowNum(); //文件最大行数
int totalColumn = xssfSheet.getRow(0).getLastCellNum(); //表头最大列数 // 为了返回值是Object[][],定义一个多行单列的二维数组
HashMap<String, String>[][] arr = new HashMap[totalRow][1]; // 对数组中所有元素hashmap进行初始化,除去header那行
if (totalRow > 1) {
for (int i = 0; i < totalRow; i++) {
arr[i][0] = new HashMap<String, String>();
}
} else {
System.out.println("excel中没有数据");
} //获取表头内容
ArrayList<String> header = new ArrayList<String>();
for (int c = 0; c < totalColumn; c++) {
String cellValue = ExcelHandle.getCellValue(xssfSheet.getRow(0).getCell(c));
header.add(cellValue);
// System.out.println("###" + cellValue);
} // 循环行Row
for (int rowNum = 1; rowNum <=totalRow; rowNum++) {
XSSFRow xssfRow = xssfSheet.getRow(rowNum);
if (xssfRow == null) {
continue;
}
// 循环列Column
for (int columnNum = 0; columnNum < totalColumn; columnNum++) {
XSSFCell xssfCell = xssfRow.getCell(columnNum);
if (xssfCell != null) {
String cellValue = ExcelHandle.getCellValue(xssfSheet.getRow(rowNum).getCell(columnNum));
arr[rowNum - 1][0].put(header.get(columnNum), cellValue);
System.out.print(" " + getCellValue(xssfSheet.getRow(rowNum).getCell(columnNum)));
continue;
}
}
}
return arr;
} /**
* 取表格值
* @param xssfCell XSSFCell类型对象,表示单元格。
* @return:返回单元格数值
*/ public static String getCellValue(XSSFCell xssfCell) {
if (xssfCell.getCellType() == xssfCell.CELL_TYPE_BOOLEAN) {
return String.valueOf(xssfCell.getBooleanCellValue());
} else if (xssfCell.getCellType() == xssfCell.CELL_TYPE_NUMERIC) {
return new BigDecimal(xssfCell.getNumericCellValue()).toPlainString();
// return String.valueOf(xssfCell.getNumericCellValue());
} else {
return String.valueOf(xssfCell.getStringCellValue());
}
} @Test
public void testExcelReader() throws IOException {
String file = "src/main/resources/case/UserEmailService/TestSelectEmailBillCountByUserId.xlsx";;
Object a[][]=readXlsx(file, "工作表1"); } }

Junit测试Spring应用Dubbo测试框架之-Excel 工具类的更多相关文章

  1. TestNG参数化测试Spring应用Dubbo接口

    一.配置dubbo的Bean文件: 配置spring-dubbo.xml文件: <dubbo:reference interface="com.datatrees.basisdata. ...

  2. Maven基础&&Spring框架阶段常用工具类整理

    常用工具类 1.密码加密工具类: package com.itheima.utils; import java.security.MessageDigest; import sun.misc.BASE ...

  3. Java基础 @org.junit.Test-单元测试方法 + 操纵Collection和Map的工具类 : Collections 的sort/binarySearch/max/min等静态方法

      单元测试代码:  ( 在IDEA中先输入'@Test '然后根据提示进行自动修订即可!!运行时直接运行即可! 若有多个单元测试块的时候,直接把鼠标放在哪里就自动在哪里运行那个单元块) import ...

  4. Junit参数化测试Spring应用Dubbo接口

    一.创建基础类. package com.tree.autotest; import org.junit.Before;import org.springframework.context.annot ...

  5. spring.net +dapper 打造简易的DataAccess 工具类.

    public class DBUtil { /// <summary> /// 数据库连接字符串 /// </summary> private static string Da ...

  6. ssh框架中,工具类调用service层方法(参考https://www.cnblogs.com/l412382979/p/8526945.html)

    代码如下: package common.dataService; import javax.annotation.PostConstruct; import org.springframework. ...

  7. spring 中 PO与DTO相互转换的工具类

    public class BeanMapper { /** * 持有Dozer单例, 避免重复创建DozerMapper消耗资源. */ private static DozerBeanMapper ...

  8. Java集合框架:Collections工具类

    java.util.Collections工具类提供非常多实用的方法.使得程序员操作集合类的时候更加的方便easy,这些方法都是静态的. 整个Collections工具类源代码几乎相同有4000行.我 ...

  9. Java集合框架:Arrays工具类

    java.util.Arrays类能方便地操作数组,它提供的方法都是静态的.整个Arrays工具类的实现有3000+行.可是归纳总结一下可知它有下面功能(9个): 1. asList 定义: @Saf ...

随机推荐

  1. git更新远程仓库代码到本地

    1 使用命令查看连接的远程的仓库 git remote -v 2 远程获取代码 git fetch origin master 如果出现 Already up-to-date 说明代码更新好了 出现 ...

  2. Interllij IDEA 注释模板(类和方法)

    类上的注释: file->setting->Editor->Filr and Code Templates->Includes->File Header /** * @A ...

  3. 234. Palindrome Linked List【Easy】【判断链表是否回文】

    Given a singly linked list, determine if it is a palindrome. Example 1: Input: 1->2 Output: false ...

  4. POJ1845 Sumdiv [数论,逆元]

    题目传送门 Sumdiv Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 26041   Accepted: 6430 Des ...

  5. win7家庭版如何获得管理员权限?

    1.首先,打开你的命令提示符,输入cmd.有一点非常重要,如图所示,我们必须“以管理员的方式打开”.只有以管理员身份打开,那么接下来要敲打的命令才会成功. 2. 打开命令提示符后,在输入框输入net ...

  6. 数学【CF743C】Vladik and fractions

    Description 请找出一组合法的解使得\(\frac {1}{x} + \frac{1}{y} + \frac {1}{z} = \frac {2}{n}\)成立 其中\(x,y,z\)为正整 ...

  7. 树链剖分【CF165D】Beard Graph

    Description 给定一棵树,有m次操作. 1 x 把第x条边染成黑色 2 x 把第x条边染成白色 3 x y 查询x~y之间的黑边数,存在白边输出-1 Input 第1行为一个整数\(n\), ...

  8. 洛谷——P2121 拆地毯

    P2121 拆地毯 题目背景 还记得 NOIP 2011 提高组 Day1 中的铺地毯吗?时光飞逝,光阴荏苒,三年过去了.组织者精心准备的颁奖典礼早已结束,留下的则是被人们踩过的地毯.请你来解决类似于 ...

  9. Arduino可穿戴开发入门教程LilyPad和LilyPad Simple的介绍

    Arduino可穿戴开发入门教程LilyPad和LilyPad Simple的介绍 LilyPad和LilyPad Simple的介绍 LilyPad和LilyPad Simple是LilyPad微控 ...

  10. 20162312Java结对编程之挑战出题

    需求分析 实现去重出题,并以命令行参数形式指定题目要求. 设计思路 具体的思路: 思路一: 原本我和春旺商量通过集合中的元素的不重复性进行去重.但是运算符多也导致重复的数字多,去重的数量也大大增多越到 ...