poj1236tarjan算法,明明和网上的代码一样,为什么测试?
不知道对不对,强连通图忘了,#include#includeusing namespace std;#define N 105int map[N][N],in[N],out[N],dfn[N],low[N],belong[N];int instack[N],scc,index,n;stackS;void tarjan(int *x){ int i,v; dfn[*x]=low[*x]=index; index ; S.push(*x); instack[*x]=1; for(i=0;ilow[i]?low[i]:low[*x]; } else if(instack[i]) low[*x]=low[*x]>dfn[i]?dfn[i]:low[*x]; } if(low[*x]==dfn[*x]) { while(1) { v=S.top(); S.pop(); belong[v]=scc; instack[v]=0; if(v==*x) break; } scc ; }}int main(){ int i,j,n,ind,outd; while(scanf("%d",&n)!=EOF) { scc=index=0; memset(map,0,sizeof(map)); memset(dfn,-1,sizeof(dfn)); memset(instack,0,sizeof(instack)); for(i=0;ioutd?ind:outd); } return 0;}
Word文档宣传单上小喇叭标识在哪?
word模版,另存成test.xml ,然后修改参数 。
将test.xml改为test.ftl.然后用网上的这段代码生成word文档。
打开时总是提示如下图(数据填入正确)public void createDoc() {//要填入模本的数据文件Map dataMap=new HashMap();getData(dataMap);//设置模本装置方法和路径,FreeMarker支持多种模板装载方法。
可以重servlet,classpath,数据库装载,//这里我们的模板是放在com.havenliu.document.template包下面configuration.setClassForTemplateLoading(this.getClass(), "");Template t=null;try {//test.ftl为要装载的模板t = configuration.getTemplate("test.ftl");} catch (IOException e) {e.printStackTrace();}//输出文档路径及名称File outFile = new File("D:/outFile.xml");Writer out = null;try {out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile)));} catch (FileNotFoundException e1) {e1.printStackTrace();}try {t.process(dataMap, out);} catch (TemplateException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}finally{try {out.close(); //释放流} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}}}
有个项目,用jsp做,要将多个WORD文档链接起来,并且做成好像在...
1-apache的POI,此方法对Excel的导出做的很好,目前对Word的导出方面的功能尚未完全。
2-纯JavaScript脚本实现。
主要通过客户端调用本机Office组件来实现。
3-在JSP页面引入头文件实现。
纯JavaScript脚本实现细节方面大体是创建一个word组件ActiveXObject('Word.Application'),用js通过表ID取得表内容然后保存到word,要注意的是js实现有很多不好的地方,例如Internet选项需要把ActiveX空间全部启用,安全级别设置为中。
这样的话岂不是每台机器都要配置一下。
其次每次生成word文档以后弹出对话框(无法保存此文件,因为它已在别处打开(C:\...\STARTUP\Powerword.dot)),出现此问题就需要把C:\Documents and Settings\当前用户名\Application Data\Microsoft\Word\STARTUP下的Powerword.dot文件删除,每次遇到此问题就需要删除文件来解决,十分不方便。
JSP页面引入来实现Word保存就方便多了,但是也有不足的地方,首先如果需要引入如果需要下载的话就引入其实如果大家用框架做就方便多了,比如Struts2。
在Action里直接写如下代码:if(out!=null){String fileName="";fileName+="评价报告.doc";try {HttpServletResponse response = ServletActionContext.getResponse();response.setHeader("Content-disposition","attachment; filename="+new String(fileName.getBytes("GB2312"), "8859_1"));} catch (UnsupportedEncodingException e) {e.printStackTrace();}out是jsp页面表单元素,一个button,用于提交表单到相应Action进行Word下载。
Action设置jsp页面头文件。
这样每次点击button就可以把相应jsp页面的内容保存到Word中并且支持下载,Word中内容并且是可编辑状态。
不足的地方在于由于表内容是动态生成,有的需要先查看在下载Word,就需要另外建立一个新JSP页面进行Word下载,当然首先要在struts.xml里配置好页面转向。
新建立的页面传值同查看页面要保持一样。
一道acm题
看看下面的代码,或许对你有启发哦~~~#include #include using namespace std;void equal(char *a,char*b){int i;for(i=0;i a[i]=b[i];}int main(){int i,j;char a[101][7];for(i=0;;i++){cin>>a[i];if(a[i][0]=='X') break;}char b[100][7];int m;for(m=0;;m++){cin>>b[m];if(b[m][0]=='X') break;}int n;for(n=0;n{int k;for(k=0;;k++)if(b[n][k]=='\0') break;int num=0;sort(b[n],b[n]+k);char dw[7];char cun[101][7];int q=0;for(j=0;j{int l;equal(dw,a[j]);for(l=0;;l++)if(dw[l]=='\0') break;sort(dw,dw+l);if(strcmp(b[n],dw)==0){num++;equal(cun[q],a[j]);q++;}}char temp[7];int x,y;for(x=0;xfor(y=0;yif(strcmp(cun[y],cun[y+1])>0){equal(temp,cun[y]);equal(cun[y],cun[y+1]);equal(cun[y+1],temp);}for(x=0;x{cout }if(num==0) cout cout}return 0;}
springmvc poi 导出word 复选框 怎么用
Apache POI是Apache软件基金会的开放源码函式库,POI提供API给Java程序对Microsoft Office格式档案读和写的功能。
这里的方法支持导出excel至项目所在服务器,或导出至客户端浏览器供用户下载,下面我把两个实例都放出来。
1.下载所需POI的jar包,并导入项目。
2.添加一个User类,用于存放用户实体,类中内容如下:1 package com.mvc.po;23 public class User {4 private int id;5 private String name;6 private String password;7 private int age;89 public User() {10 11 }12 13 public User(int id, String name, String password, int age) {14 this.id = id;15 this.name = name;16 this.password = password;17 this.age = age;18 }19 public int getId() {20 return id;21 }22 public void setId(int id) {23 this.id = id;24 }25 public String getName() {26 return name;27 }28 public void setName(String name) {29 this.name = name;30 }31 public String getPassword() {32 return password;33 }34 public void setPassword(String password) {35 this.password = password;36 }37 public int getAge() {38 return age;39 }40 public void setAge(int age) {41 this.age = age;42 }43 }3.添加一个UserController类,类中内容如下:1 package com.mvc.controller;23 import java.text.SimpleDateFormat;4 import java.util.Date;56 import javax.servlet.ServletOutputStream;7 import javax.servlet.http.HttpServletResponse;89 import org.springframework.stereotype.Controller;10 import org.springframework.beans.factory.annotation.Autowired;11 import org.springframework.web.bind.annotation.RequestMapping;12 import org.springframework.web.bind.annotation.ResponseBody;13 14 import com.mvc.po.User;15 import com.mvc.service.UserService;16 17 @Controller18 public class UserController {19 20 @Autowired21 private UserService userService;22 23 @RequestMapping("/export.do")24 public @ResponseBody String export(HttpServletResponse response){ 25 response.setContentType("application/binary;charset=utf-8");26 try{27 ServletOutputStream out=response.getOutputStream();28 String fileName=new String(("UserInfo "+ new SimpleDateFormat("yyyy-MM-dd").format(new Date())).getBytes(),"UTF-8");29 response.setHeader("Content-disposition", "attachment; filename=" + fileName + ".xls");30 String[] titles = { "用户编号", "用户姓名", "用户密码", "用户年龄" }; 31 userService.export(titles, out);32 return "success";33 } catch(Exception e){34 e.printStackTrace();35 return "导出信息失败";36 }37 }38 }4.添加一个接口类UserService和实现类UserServiceImpl,类中内容如下:1 package com.mvc.service;2 3 import javax.servlet.ServletOutputStream;4 import com.mvc.po.User;5 6 public interface UserService {7 public void export(String[] titles, ServletOutputStream out);8 }1 package com.mvc.service.impl;23 import java.text.SimpleDateFormat;4 import java.util.List;56 import javax.servlet.ServletOutputStream;78 import com.mvc.dao.UserDAO;9 import com.mvc.po.User;10 import com.mvc.service.UserService;11 12 import org.apache.poi.hssf.usermodel.HSSFCell;13 import org.apache.poi.hssf.usermodel.HSSFCellStyle;14 import org.apache.poi.hssf.usermodel.HSSFRow;15 import org.apache.poi.hssf.usermodel.HSSFSheet;16 import org.apache.poi.hssf.usermodel.HSSFWorkbook;17 import org.springframework.beans.factory.annotation.Autowired;18 import org.springframework.stereotype.Service;19 20 @Service21 public class UserServiceImpl implements UserService {22 23 @Autowired24 private UserDAO userDAO;25 26 @Override27 public void export(String[] titles, ServletOutputStream out) { 28 try{29 // 第一步,创建一个workbook,对应一个Excel文件30 HSSFWorkbook workbook = new HSSFWorkbook();31 // 第二步,在webbook中添加一个sheet,对应Excel文件中的sheet32 HSSFSheet hssfSheet = workbook.createSheet("sheet1");33 // 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short34 HSSFRow hssfRow = hssfSheet.createRow(0);35 // 第四步,创建单元格,并设置值表头 设置表头居中36 HSSFCellStyle hssfCellStyle = workbook.createCellStyle();37 //居中样式38 hssfCellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);39 40 HSSFCell hssfCell = null;41 for (int i = 0; i < titles.length; i++) {42 hssfCell = hssfRow.createCell(i);//列索引从0开始43 hssfCell.setCellValue(titles[i]);//列名144 hssfCell.setCellStyle(hssfCellStyle);//列居中显示 45 }46 47 // 第五步,写入实体数据 48 List users = userDAO.query(); 49 50 SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");51 if(users != null && !users.isEmpty()){52 for (int i = 0; i < users.size(); i++) {53 hssfRow = hssfSheet.createRow(i+1); 54...
求助word APPCRASH问题
首先我用的技术是 poi 这是代码,一个工具类得调用public class WordUtil { /** * 基于模板文件导出 word 文档,此方法主要是用来处理文档中需要替换的文本内容,对图片和表格无效 * * @param templatePath * 模板文件的路径,要求路径中要包含全名,并且模板文件只能是 07 及以上格式,即 docx 的文件 * @param destFilePath * 导出文件的存放路径,包含文件名,例如,E:/test/小区公告.docx * @param data * 用来替换文档中预定义的字符串,要求预定义的字符串与 data 中的 key 值要相同 */ public static void exportWordByTemplate(String templatePath, String destFilePath, Map data) { FileOutputStream out = null; XWPFDocument doc = null; try { doc = new XWPFDocument(POIXMLDocument.openPackage(templatePath)); List listRun; List listParagraphs = doc.getParagraphs(); for (int i = 0; i < listParagraphs.size(); i++) { listRun = listParagraphs.get(i).getRuns(); for (int j = 0; j < listRun.size(); j++) { if (data.get(listRun.get(j).getText(0)) != null) { String val = data.get(listRun.get(j).getText(0)); listRun.get(j).setText(val, 0); } } } File destFile = new File(destFilePath); if (!destFile.getParentFile().exists()) { destFile.getParentFile().mkdirs(); } out = new FileOutputStream(destFilePath); doc.write(out); } catch (IOException e) { e.printStackTrace(); } finally { try { if (out != null) out.close(); } catch (IOException e) { e.printStackTrace(); } } } /** * 基于模板文件导出 word 文档,该方法支持03格式,但是此方法只能保留文档内容,不能保留文档中的样式和图片,建议将模板使用 07 的格式保存 * * @param templatePath * 模板文件的路径 * @param destFilePath * 导出文件的存放路径,包含文件名,例如,E:/test/小区公告.doc * @param data * 用来替换文档中预定义的字符串,要求预定义的字符串与 data 中的 key 值要相同 */ public static void export03WordByTemplate(String templatePath, String destFilePath, Map data) { try { WordExtractor doc = new WordExtractor(new FileInputStream( templatePath)); String content = doc.getText(); for (String key : data.keySet()) { content = content.replaceAll(key, data.get(key)); } byte b[] = content.getBytes(); ByteArrayInputStream bais = new ByteArrayInputStream(b); POIFSFileSystem fs = new POIFSFileSystem(); DirectoryEntry directory = fs.getRoot(); directory.createDocument("WordDocument", bais); FileOutputStream ostream = new FileOutputStream(destFilePath); fs.writeFilesystem(ostream); bais.close(); ostream.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public static void main(String[] args) throws Exception { Map maps = new HashMap(); maps.put("appellation", "万达公寓业主:"); maps.put( "main_body", "输出的内容"); maps.put("date", "2013年1月23日"); exportWordByTemplate("E:/sss 2.docx", "E:/test/test.doc", maps);}}"E:/sss 2.docx 模板存放的地址。
E:/test/test.doc 新生成的地址。
C语言中,如何用多个文件编写程序
1. 将一个函数写在一个文件里,然后再在另一个文件里用“include”包含这个文件。
2. 举例:在文件c1.c里编一个函数:void printWord(){printf("Hello!world!");}再建立一个文件c2.c,文件开头写上#include"c1.c",就可以调用c1.c里的函数printword()了这样通过include操作,可以把任意多个文件连接起来,编译成一个程序运行。
用adobe acrobat的adobe pdf把word转换成pdf转换完毕后弹出一个含...
%%[ ProductName: Distiller ]%%94xufd not found, using Courier.%%[ Error: typecheck; OffendingCommand: show ]%%Stack:(^)%%[ Flushing: rest of job (to end-of-file) will be ignored ]%%%%[ Warning: PostScript error. No PDF file produced. ] %%我是在Adobe PDF打印出错的log文件夹中看到的。
报错原因为:字体缺失纠正步骤:到控制面板——打印机——pdf 打印机 上点右键——Adobe PDF Settings——Rely on system fonts only; do not use document fonts选项去掉。
转载请注明出处51数据库 » poj 2817 wordstack