/-------------------------------------------------------/
/ 俄罗斯方块 /
/ /
/-------------------------------------------------------/
/------------- Compile ------------------------------ /
/ [in os mode:] /
/ bgiobj egavga /
/ tlib lib\graphicslib+egavga /
/ [in TC: ] /
/ make exe /
/-------------------------------------------------------/
#include <stdlibh>
#include <graphicsh>
#include <biosh>
#define mDRAW 5
#define mLINE 6
#define mADOWN 7
#define mGEN 8
#define mLEFT 75
#define mRIGHT 77
#define mSPACE 57
#define mDOWN 80
#define mESC 1
#define TIMEINT 2
#define MAXX 9
#define MAXY 30
#define BACKCOLOR BLACK
#define WINX 50
#define WINY 470
#define GAP 6
#define AREAX (WINX+GAP)
#define AREAY (WINY-GAP)
#define BOXW 15
int oldarea[MAXY+1][MAXX];
int area[MAXY+1][MAXX];
int actW,actH,actX,actY;
int curX,curY,curColor,curW,curH;
int newX,newY,newColor,newW,newH;
int active;
int box[4][4];
int FORCOLOR;
int MESSAGE;
int BOX[7][4][4]={
{
{1,1,1,1},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0}
},{
{1,1,1,0},
{1,0,0,0},
{0,0,0,0},
{0,0,0,0}
},{
{1,1,1,0},
{0,0,1,0},
{0,0,0,0},
{0,0,0,0}
},{
{1,1,1,0},
{0,1,0,0},
{0,0,0,0},
{0,0,0,0}
},{
{1,1,0,0},
{0,1,1,0},
{0,0,0,0},
{0,0,0,0}
},{
{0,1,1,0},
{1,1,0,0},
{0,0,0,0},
{0,0,0,0}
},{
{1,1,0,0},
{1,1,0,0},
{0,0,0,0},
{0,0,0,0}
}
};
void init();
void draw();
int genBox();
int getKey();
void lineFull();
int moveLeft();
int moveRight();
int moveDown();
int rotate();
int getW();
int getH();
void clearOldBox();
void putNewBox();
int collisionRotate(int box[][4]);
void getMessage();
void dispatchMessage();
int timeCome();
void fallDown();
int gameOver();
main()
{
int i;
init();
do
{
getMessage();
dispatchMessage();
}
while(!gameOver());
getch();
closegraph();
}
void getMessage()
{
if(MESSAGE) return;
if(timeCome())
{
MESSAGE=mADOWN;
return;
}
if(bioskey(1))
{
MESSAGE=bioskey(0)>>8;
return;
}
}
void dispatchMessage()
{
switch(MESSAGE)
{
case mLEFT: moveLeft();break;
case mRIGHT: moveRight();break;
case mADOWN: moveDown();break;
case mSPACE: rotate();break;
case mDOWN: fallDown(); break;
case mDRAW: draw();break;
case mLINE: lineFull();break;
case mGEN: genBox();break;
case mESC: closegraph(); exit(0);
default: MESSAGE=0;
}
}
void fallDown()
{
while(active)
{
moveDown(); draw();
}
MESSAGE=mLINE;
}
int timeCome()
{
static long tm, old;
tm=biostime(0,tm);
if(tm-old<TIMEINT) return 0;
else
{
old=tm; return 1;
}
}
void init()
{
int i,j,x1,y1,x2,y2;
int driver=DETECT, mode=0;
randomize();
registerbgidriver(EGAVGA_driver);
initgraph(&driver,&mode,"");
cleardevice();
setfillstyle(SOLID_FILL,BLUE);
bar(0,0,639,479);
x1=AREAX;
y1=AREAY-BOXWMAXY;
x2=AREAX+MAXXBOXW;
y2=AREAY;
rectangle(--x1,--y1,++x2,++y2);
setfillstyle(SOLID_FILL,BLACK);
bar(++x1,++y1,--x2,--y2);
y1=AREAY-MAXYBOXW; y2=AREAY;
setcolor(DARKGRAY);
for(i=0;i<MAXX;i++)
{
x1=AREAX+iBOXW;
line(x1,y1,x1,y2);
}
x1=AREAX; x2=x1+MAXXBOXW;
for(j=0;j<MAXY;j++)
{
y1=AREAY-jBOXW;
line(x1,y1,x2,y1);
}
for(j=0;j<MAXY;j++)
for(i=0;i<MAXX;i++)
area[j][i]=oldarea[j][i]=0;
actX=0; actY=0; actW=MAXX-1; actH=MAXY-1;
draw();
MESSAGE=mGEN;
}
int genBox()
{
int i,j,boxidx;
boxidx=random(7); FORCOLOR=random(7)+1;
for(j=0;j<4;j++)
for(i=0;i<4;i++)
box[j][i]=BOX[boxidx][j][i];
curW=getW(); curH=getH();
curX=(MAXX+curW)/2;
if(curX+curW>=MAXX)curX=MAXX-1-curW;
curY=MAXY-1-curH;
newX=curX; newY=curY; actX=curX;actY=curY;
actW=newW=curW; actH=newH=curH;
active=1;
if(collision(box)) return 0;
putNewBox();
draw(); MESSAGE=0;
return 1;
}
void lineFull()
{
int row,col, rowEnd,full,i,j;
rowEnd=newY+newH;
if(rowEnd>=MAXY-1) rowEnd=MAXY-2;
for(row=newY; row<=rowEnd;)
{
full=1;
for(col=0;col<MAXX;col++)
if(!area[row][col]){full=0; break;}
if(!full){++row; continue;}
for(j=row; j<MAXY-1;j++)
for(i=0;i<MAXX;i++)
area[j][i]=area[j+1][i];
actX=0;actY=row; actW=MAXX-1; actH=MAXY-1-row;
draw(); rowEnd--;
}
MESSAGE=mGEN;
}
void draw()
{
int row,col,x1,y1,x2,y2;
for(row=actY;row<=actY+actH;row++)
for(col=actX;col<=actX+actW;col++)
if(area[row][col]!=oldarea[row][col])
{
if(area[row][col]==0)
setfillstyle(SOLID_FILL,BACKCOLOR);
else
setfillstyle(SOLID_FILL,FORCOLOR);
x1=AREAX+colBOXW; x2=x1+BOXW;
y1=AREAY-(row+1)BOXW; y2=y1+BOXW;
bar(++x1,++y1,--x2,--y2);
oldarea[row][col]=area[row][col];
}
MESSAGE=0;
}
int moveLeft()
{
newX=curX-1; clearOldBox();
if(collision(box))
{
newX=curX;
putNewBox();
MESSAGE=0;
return 0;
}
putNewBox();
actW=curW+1; actX=curX=newX;
MESSAGE=mDRAW;
return 1;
}
int moveRight()
{
newX=curX+1; clearOldBox();
if(collision(box))
{
newX=curX;
putNewBox();
MESSAGE=0;
return 0;
}
putNewBox();
actW=curW+1; actX=curX; curX=newX;
MESSAGE=mDRAW;
return 1;
}
int moveDown()
{
int i,j;
newY=curY-1;
clearOldBox();
if(collision(box))
{
newY=curY;
putNewBox();
active=0;
MESSAGE=mLINE;
return 0;
}
putNewBox();
actH=curH+1; actY=newY; curY=newY;
MESSAGE=mDRAW;
return 1;
}
int rotate()
{
int newBox[4][4];
int i,j;
clearOldBox();
for(j=0;j<4;j++)
for(i=0;i<4;i++)
newBox[j][i]=0;
for(j=0;j<4;j++)
for(i=0;i<4;i++)
newBox[curW-i][j]=box[j][i];
newW=curH; newH=curW;
if(collisionRotate(newBox))
{
newW=curW; newH=curH; newX=curX; newY=curY;
putNewBox();
MESSAGE=0;
return 0;
}
for(j=0;j<4;j++)
for(i=0;i<4;i++)
box[j][i]=newBox[j][i];
putNewBox();
actH=newH>curH newH:curH;
actW=curX+actH-newX;
actX=newX; actY=newY; curX=newX;
curY=newY; curW=newW; curH=newH;
MESSAGE=mDRAW;
return 1;
}
int getW()
{
int i,j;
for(i=3;i>0;i--)
for(j=0;j<4;j++)
if(box[j][i]) return i;
return 0;
}
int getH()
{
int i,j;
for(j=3;j>0;j--)
for(i=0;i<4;i++)
if(box[j][i]) return j;
return 0;
}
void clearOldBox()
{
int i,j;
for(j=0;j<=curH; j++)
for(i=0;i<=curW; i++)
if(box[j][i])
area[curY+j][curX+i]=0;
}
void putNewBox()
{
int i,j;
for(j=0;j<=newH;j++)
for(i=0;i<=newW;i++)
if(box[j][i])
area[newY+j][newX+i]=FORCOLOR;
}
int collision(int cbox[][4])
{
int i,j;
if(newX<0) return 1;
if(newX+newW>=MAXX) return 1;
if(newY<0) return 1;
for(j=0;j<=newH;j++)
for(i=0;i<=newW;i++)
if(area[newY+j][newX+i]&&cbox[j][i]) return 1;
return 0;
}
int collisionRotate(int cbox[][4])
{
int i,j;
if(newX+newW>=MAXX) newX=MAXX-1-newW;
if(newY+newH>=MAXY) newY=MAXY-1-newH;
if(collision(cbox)) return 1;
for(i=0;i<=newW;i++)
for(j=0;j<=newH;j++)
if(area[newY+j][newX+i])
{
newX-=newW-i+1; goto L;
}
L: return collision(cbox);
}
int gameOver()
{
if(!active &&(curY+curH>MAXY-3)) return 1;
else return 0;
}
/ the end /
呵呵、、、出错很正常啊!你刚开始学习,不要太把错误放在心上,重要是解决错误的办法和过程。至于那上万行的代码,大型程序都是模块化编写的,不是一c文件。那是要分成若干c文件,不能c文件中放着不同的函数(对应相应的功能),单个c文件编译容易发现错误。最后将所有的c文件整体编译。就这样!!模块化编程思想!!
package comeraytctmsZimport;
import javaioFileInputStream;
import javaioIOException;
import javaioInputStream;
import javalangreflectField;
import javautilArrayList;
import javautilHashMap;
import javautilIterator;
import javautilList;
import orgapachecommonscollectionsfunctorsForClosure;
import orgapachepoihssfusermodelHSSFCell;
import orgapachepoihssfusermodelHSSFWorkbook;
import orgapachepoissusermodelCell;
import orgapachepoissusermodelRow;
import orgapachepoissusermodelSheet;
import orgapachepoissusermodelWorkbook;
import orgapachepoixssfusermodelXSSFWorkbook;
import orgslf4jLogger;
import orgslf4jLoggerFactory;
import comalibabafastjsonJSONArray;
import comalibabafastjsonJSONObject;
import comeraytctmssystemstandardxnetCtmsXNetContext;
import comeraytxnet4jXNetCommand;
import comeraytxnet4jXNetData;
public class ReadForwardExcelServiceImpl implements ReadForwardExcelService {
private SearchPosDao searchForwardDao;
public SearchPosDao getSearchForwardDao() {
return searchForwardDao;
}
public void setSearchForwardDao(SearchPosDao searchForwardDao) {
thissearchForwardDao = searchForwardDao;
}
protected Logger logger = LoggerFactory
getLogger(thisgetClass()getName());
private Workbook wb;
// private JSONObject jsonObject = new JSONObject();
private List<Object> list_key = new ArrayList<Object>();
private List<Object> list_body = new ArrayList<Object>();
private List<HashMap<String,Object>> list_map = new ArrayList<HashMap<String,Object>>();
private CtmsXNetContext ctmsXNetContext;
private String filename3;
public String getFilename3() {
return filename3;
}
public void setFilename3(String filename3) {
thisfilename3 = filename3;
}
public String getFilename4() {
return filename4;
}
public void setFilename4(String filename4) {
thisfilename4 = filename4;
}
private String filename4;
public void setCtmsXNetContext(CtmsXNetContext ctmsXNetContext) {
thisctmsXNetContext = ctmsXNetContext;
}
public void init() {
readXml(filename3);
}
public void readXml(String fileName) {
try {
InputStream input = new FileInputStream(fileName); // 建立输入流
// 根据文件格式2003来初始化
wb = new HSSFWorkbook(input);
Sheet sheet = wbgetSheetAt(0); // 获得第一个表单
Iterator<Row> rows = sheetrowIterator(); // 获得第一个表单的迭代器
for(int i=0;i<sheetgetPhysicalNumberOfRows();i++) {
Row row = rowsnext(); // 获得行数据
//Systemoutprintln(sheetgetPhysicalNumberOfRows()+"+++++");
Iterator<Cell> cells = rowcellIterator();// 获得第i行的迭代器
HashMap<String, String> HashBegain=new HashMap<String, String>();
for(int j=0;j<rowgetPhysicalNumberOfCells();j++){
//Systemoutprintln(rowgetPhysicalNumberOfCells()+"+++++"+j);
Cell cell = cellsnext();
if(i==0||i==7){
list_keyadd(cellgetStringCellValue());
}else {
if(cellgetCellType()== cellCELL_TYPE_NUMERIC){
HashBegainput((String) list_keyget(j), StringvalueOf(cellgetNumericCellValue()));
}
else{HashBegainput((String) list_keyget(j), cellgetStringCellValue());}
}
}
if(i!=0&&i!=7){
list_bodyadd(HashBegain);
}
if(i==6){
list_key = new ArrayList<Object>();
}
}
installJson();
readExcelEqual();
} catch (IOException ex) {
exprintStackTrace();
}
}
// 组装即期交易json报文,并发送
public void installJson() {
String headStr = "{Head:" + "{\"chanelNo\":1508170004977,"
+ "\"dataCount\":\"1\"," + "\"eventType\":\"1\","
+ "\"msgNo\":\"1508170004977-20150917171754\","
+ "\"msgType\":\"1\"," + "\"sendingTime\":\"20150917171754\","
+ "\"source\":\"TR1\"," + "\"subSource\":\"TR1\","
+ "\"version\":\"10\"}," + "Body:"
+ JSONArraytoJSONString(list_body)replaceAll("\"", "'") + "}";
Systemoutprintln(headStr);
try {
Threadsleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
eprintStackTrace();
}
sendXNetTradeData(headStr, "RK1INTrade", "UTF-8");
}
// 发送到xnetd
public void sendXNetTradeData(String sendJson, String title, String charset) {
XNetData xnetData = new XNetData();
xnetDatasetData(sendJson, charset);
xnetDatasetTitle(title);
xnetDatasetCommand(XNetCommandTITLE);
if (ctmsXNetContextgetCtmsXnetSocket()isLoginOK()) {
ctmsXNetContextgetCtmsXnetSocket()sendData(xnetData);
} else {
loggerwarn("CtmsXnet no login sendXNetData[" + title
+ "] return");
}
}
// 打印json属性
public static void printClassInfo(Object object) {
Field[] fields = objectgetClass()getDeclaredFields();
for (int i = 0; i < fieldslength; i++) {
try {
boolean accessFlag = fields[i]isAccessible();
fields[i]setAccessible(true);
String varName = fields[i]getName();
Object varValue = fields[i]get(object);
Systemoutprintln(varName + "=" + varValue);
fields[i]setAccessible(accessFlag);
} catch (Exception e) {
eprintStackTrace();
}
}
}
//获取excel结果数据,并进行比较
public void readExcelEqual() {
//读取excel头寸数据
HashMap<String, String> HashEnd=new HashMap<String, String>();
Workbook wb1;
List<Object> list_keyBody = new ArrayList<Object>();
List<HashMap> list_keyBody2 = new ArrayList<HashMap>();
//List<HashMap<String,Object>> list_keyBody2 = new ArrayList<HashMap<String,Object>>();
boolean END=false;
try {
InputStream input = new FileInputStream(filename4); // 建立输入流
wb1 = new HSSFWorkbook(input);
Sheet sheet = wb1getSheetAt(0); // 获得第一个表单
Iterator<Row> rows = sheetrowIterator(); // 获得第一个表单的迭代器
int i = 0;
while (rowshasNext()) {
HashEnd=new HashMap<String, String>();
Row row = rowsnext(); // 获得行数据
for (int j = 0; j < rowgetLastCellNum(); j++) {
//Systemoutprintln(rowgetLastCellNum()+"XXXXX");
Cell cell = rowgetCell(j);
if(i==0){
list_keyBodyadd(cellgetStringCellValue());
}else{
if(cellgetCellType()==cellCELL_TYPE_NUMERIC){
HashEndput((String) list_keyBodyget(j), StringvalueOf(cellgetNumericCellValue()));
}
else
{
HashEndput((String) list_keyBodyget(j), cellgetStringCellValue());
}
}
}
if(i!=0){
list_keyBody2add(HashEnd);}
i++;
}
} catch (IOException ex) {
exprintStackTrace();
}
//从数据库获取头寸数据
try {
Threadsleep(10000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
eprintStackTrace();
}
list_map=searchForwardDaofindForwardPos();
//输出计算正确与否
for(int k=0;k<list_mapsize();k++){
if(END=list_mapget(k)get("AMOUNT_1")toString()equals((String) list_keyBody2get(k)get("AMOUNT_1")))
{
loggerdebug("远期第"+k+"组 货币1金额计算正确"+" Amount1="+list_mapget(k)get("AMOUNT_1")toString());
}else {
loggerdebug("远期第"+k+"组 货币1金额计算不正确"+"left="+list_mapget(k)get("AMOUNT_1")toString()+" right="+list_keyBody2get(k)get("AMOUNT_1"));
}
if(END=list_mapget(k)get("AMOUNT_2")toString()equals((String) list_keyBody2get(k)get("AMOUNT_2")))
{
loggerdebug("远期第"+k+"组 货币2金额计算正确"+" Amount2="+list_mapget(k)get("AMOUNT_2")toString());
}else {
loggerdebug("远期第"+k+"组 货币2金额计算不正确"+"left="+list_mapget(k)get("AMOUNT_2")toString()+" right="+list_keyBody2get(k)get("AMOUNT_2"));
}
if(END=list_mapget(k)get("START_PL")toString()equals((String) list_keyBody2get(k)get("START_PL")))
{
loggerdebug("远期第"+k+"组 累计损益计算正确"+" START_PL="+list_mapget(k)get("START_PL")toString());
}else {
loggerdebug("远期第"+k+"组 累计损益计算不正确"+"left="+list_mapget(k)get("START_PL")toString()+" right="+list_keyBody2get(k)get("START_PL"));
}
if(END=list_mapget(k)get("DAILY_PL")toString()equals((String) list_keyBody2get(k)get("DAILY_PL")))
{
loggerdebug("远期第"+k+"组 日止损计算正确"+" DAILY_PL="+list_mapget(k)get("DAILY_PL")toString());
}else {
loggerdebug("远期第"+k+"组 日止损计算不正确"+"left="+list_mapget(k)get("DAILY_PL")toString()+" right="+list_keyBody2get(k)get("DAILY_PL"));
}
}
}
}
#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#pragma warning (disable: 4786)
#include <vector>
#include <algorithm>
#include <conioh>
#include<windowsh>
using namespace std;
class Student
{
public:
void StuShow();
void Studenttxt();
bool duplicated(string);
void surface();
int submenu();
void chose();
void entrydata();
bool duplicated();
void searchname();
int searchID(string);
void searchsex();
void searchcha();
void updata(string);
//void deldata();
void count();
void countsex(char);
void countall();
void deldata();
void modify();
Student alterUser(Student);
private:
string name;
string number;
char sex;
int age;
string address;
string chamber;
};
//菜单
void menu()
{
cout<<"-------------------"<<endl;
cout << "1、输入学生信息"<<endl;
cout << "2、显示学生信息"<<endl;
cout << "3、查询学生信息"<<endl;
cout << "4、统计学生信息"<<endl;
cout << "5、删除学生信息"<<endl;
cout << "6、修改学生信息"<<endl;
cout << "7、清理屏幕"<<endl;
cout << "0、退出系统"<<endl;
cout<<"-------------------"<<endl;
}
//查询学生信息
void searchmenu()
{
cout<<"-------------------------"<<endl;
cout<<"1、按学号查找"<<endl;
cout<<"2、按姓名查找"<<endl;
cout<<"3、按寝室号查找"<<endl;
cout<<"4、按性别查找"<<endl;
cout<<"-------------------------"<<endl;
}
//统计的菜单
void countmenu()
{
cout<<"----------------------------"<<endl;
cout<<"请选择你要统计的内容或 *** 作:"<<endl;
cout<<"1、统计男生数"<<endl;
cout<<"2、统计女生数"<<endl;
cout<<"3、统计总人数"<<endl;
cout<<"4、按0退出"<<endl;
cout<<"----------------------------"<<endl;
}
//数据录入
void Student::entrydata()
{
Student Stu;
cout<<"您正在添加学生信息"<<endl;
cout<<"------------------"<<endl;
cout<<"请输入学号:"<<endl;
cin>>number;
cout<<"请输入姓名:"<<endl;
cin>>name;
cout<<"请输入性别,m表示男,w表示女:"<<endl;
cin>>sex;
cout<<"请输入年龄:"<<endl;
cin>>age;
cout<<"请输入住址:"<<endl;
cin>>address;
cout<<"请输入寝室号:"<<endl;
cin>>chamber;
//menu();
Studenttxt();
}
//数据保存,文本格式
void Student::Studenttxt()
{
fstream fout1("d:\\userInfotxt",ios::out|ios::app);
fout1<<number<<" "<<name<<" "<<sex<<" "<<age<<" "<<address<<" "<<chamber<<endl;
fout1close();
}
//按照学号查询
int Student::searchID(string id)
{
fstream fin("d:\\userInfotxt",ios::in);
if (finfail())
{
cout<<"Cannot open file"<<endl;
exit(1);
}
Student Stu;
int n=0;
while(!fineof())
{
fin>>Stunumber>>Stuname>>Stusex>>Stuage>>Stuaddress>>Stuchamber;
if(Stunumber=="")
break;
if(Stunumber==id)
{
cout<<Stunumber<<" "<<Stuname<<" "<<Stusex;
if (Stusex=='m')
{
cout<<"男";
}
else
cout<<"女";
cout<<" "<<Stuage<<" "<<Stuaddress<<" "<<Stuchamber<<endl;
n=1;
}
Stunumber="";
}
if(n==0)
cout<<"没有你要找的学生!!!"<<endl;
finclose();
return 0;
}
//数据读取
void Student::StuShow()
{
fstream fin("d:\\userInfotxt",ios::in);
if (finfail())
{
cout<<"d:\\userInfotxt"<<endl;
exit(1);
}
while(!fineof())
{
fin>>number>>name>>sex>>age>>address>>chamber;
if(finfail())
{
break;
}
cout<<"学号为:"<<number<<"\t姓名为:"<<name<<"\t年龄为:"<<age<<"\t住址为:"<<address<<"\t寝室号为:"<<chamber<<endl;
if (sex=='m')
{
cout<<"该名学生的性别为:男"<<endl;
}
else
cout<<"该名学生的性别为:女"<<endl;
}
finclose();
}
//删除、修改, *** 作提示界面
void chosemenu()
{
cout<<"--------------------------------"<<endl;
cout<<"1、删除该学生"<<endl;
cout<<"2、修改该学生的信息"<<endl;
cout<<"请选择你需要进行的 *** 作,输入0退出"<<endl;
}
//删改学生信息
void Student::chose()
{
while (true)
{
int n;
chosemenu();
cin>>n;
if(n==0)
break;
switch (n)
{
case 1: ;break;
case 2: ;break;
default:cout<<"输入有误请重新输入"<<endl;
}
}
}
//删除学生信息
void Student::deldata()
{
string id;
cin>>id;
cout<<"请输入要删除的学生的学号:"<<endl;
vector <Student> name;//vector 是个容器
fstream fin("userInfotxt",ios::in);
Student stu;
int n=0;
if (finfail())
{
cout<<"Cannot open fail";
exit(1);
}
while(!fineof())
{
fin>>stunumber>>stuname>>stusex>>stuage>>stuaddress
>>stuchamber;
if(stunumberlength()==0)
break;
if(stunumber==id)
{
n=1;
continue;//break是跳出循环而continue是再次继续运行循环
}
namepush_back(stu);
}
finclose();
if(n==0)
{
cout<<"没有该用户"<<endl;
}
fstream fout("userInfotxt",ios::out);
if(!fout)
{
cout<<"Cannot open file"<<endl;
exit(1);
}
for(int i=0;i<namesize();i++)
{
fout<<" "<<name[i]number<<" "<<name[i]name<<" "<<name[i]sex<<" "<<name[i]age<<" "<<name[i]address<<" "
<<name[i]chamber<<endl;
}
foutclose();
}
//修改学生信息
void Student::modify()
{
string id;
cout<<"请输入你要修改的学生号:"<<endl;
cin>>id;
vector <Student> name;
fstream fin("d:\\userInfotxt",ios::in);
Student Stu;
int n=0;
if (finfail())
{
cout<<"Cannot open fail";
exit(1);
}
while(!fineof())
{
fin>>Stunumber>>Stuname>>Stusex>>Stusex>>Stuage>>Stuaddress>>Stuchamber;
if(Stunumberlength()==0)
break;
if(Stunumber==id)
{
Stu=alterUser(Stu);
n=1;
}
namepush_back(Stu);
}
finclose();
if(n==0)
{
cout<<"没有该用户"<<endl;
return;
}
fstream fout("d:\\userInfotxt",ios::out);
if(!fout)
{
cout<<"Cannot open file"<<endl;
exit(1);
}
for(int i=0;i<namesize();i++)
{
fout<<name[i]number<<" "<<name[i]name<<" "<<name[i]sex<<" "
<<name[i]age<<" "<<name[i]address<<" "<<name[i]chamber<<endl;
}
foutclose();
}
//获取修改后的学生信息
Student Student::alterUser(Student S)
{
Student Stu;
Stuname=Sname;
cout<<"请输入你要修改的姓名:"<<Sname<<endl;
cin>>Stuname;
cout<<"请输入你要修改的性别:"<<Ssex<<endl;
cin>>Stusex;
cout<<"请输入你要修改的地址:"<<Saddress<<endl;
cin>>Stuaddress;
cout<<"请输入你要修改的寝室号:"<<Schamber<<endl;
cin>>Stuchamber;
cout<<"你确认要修改么?Yes(1)/No(0)"<<endl;
int n;
cin>>n;
if(n==1)
return Stu;
else
return S;
}
//统计
void Student::count()
{
while(true)
{
int w;
char Se;
countmenu();
cin>>w;
if(w==0)
break;
switch (w)
{
case 1: Se='m';countsex(Se);break;
case 2: Se='n'; countsex(Se);break;
case 3:;break;
default:cout<<"输入有误请重新输入"<<endl;
}
}
}
//按照性别统计
void Student::countsex(char Se)
{
fstream fin("d:\\userInfotxt",ios::in);
Student stu;
int n=0;
if (finfail())
{
cout<<"Cannot open fail";
exit(1);
}
while(!fineof())
{
fin>>stunumber>>stuname>>stusex
>>stuage>>stuaddress>>stuchamber;
if(stunamelength()==0)
break;
if(stusex==Se)
{
n++;
}
}
finclose();
cout<<(Se=='m'"男":"女")<<"生共有"<<n<<"人"<<endl;
cout<<endl;
}
//统计总人数
void Student::countall()
{
fstream fin("d:\\userInfotxt",ios::in);
Student Stu;
int n=0;
if (finfail())
{
cout<<"Cannot open fail";
exit(1);
}
while(!fineof())
{
fin>>Stunumber>>Stuname>>Stuage>>Stusex>>Stuaddress>>Stuchamber;
if(Stunumberlength()==0)
break;
n++;
}
finclose();
cout<<"共有"<<n<<"个人"<<endl;
}
//学号重复判断
bool Student::duplicated(string number)
{
Student Stu;
bool exist=false;
fstream fin("d:\\usertxt",ios::in);
if (finfail())
{
return exist;
}
while (!fineof()) //eof判断是否到文件末尾
{
fin>>Stunumber>>Stuname>>Stusex>>Stuage>>Stuaddress>>Stuchamber;
if(number==Stunumber)
{
exist=true; //表示有重名的
break;
}
}
finclose();
return exist;
}
//界面函数
void Student::surface()
{
menu();
while(true)
{
int n;
cout<<"请输入相应的数字选择 *** 作"<<endl;
cin>>n;
if(n==0)
break;
switch (n)
{
case 1: entrydata();menu();break;
case 2: StuShow();menu();break;
case 3: submenu();menu();break;
case 4: count();menu();break;
case 5: deldata();break;
case 6: modify();;break;
case 7: system("cls");break;
default:cout<<"输入有误请重新输入"<<endl;
}
}
}
//学生信息查询
int Student::submenu()
{
while (true)
{
int n;
searchmenu();
cout<<"请输入你想查找的方式,按0返回上一层"<<endl;
cin>>n;
if(n==0)
break;
switch (n)
{
case 1:
{
string id;
cout<<"请输入你要查询的学生号:"<<endl;
cin>>id;
searchID(id) ;
chose();
}break;
case 2: ;break;
case 3: ;break;
case 4: ;break;
default:cout<<"输入有误请重新输入"<<endl;
}
}
return 0;
}
int main()
{
Student Stu;
Stusurface();
return 0;
}
#include <errnoh>
#include <unistdh>
#include <sys/ioctlh>
#include <sys/typesh>
#include <sys/mmanh>
#include <sys/stath>
#include <fcntlh>
#include <linux/fbh>
#include "xorg-serverh"
#include "xf86h"
#include "xf86cmaph"
#include <xf86drmh>
#include "xf86xvh"
#include "xf86Crtch"
#include "micmaph"
#include "mali_defh"
#include "mali_fbdevh"
#include "mali_exah"
#include "mali_drih"
#include "mali_lcdh"
#include "compat-apih"
#define MALI_VERSION 4000
#define MALI_NAME "MALI"
#define MALI_DRIVER_NAME "mali"
#define PAGE_MASK (~(getpagesize() - 1))
static const OptionInfoRec MaliAvailableOptions(int chipid, int busid);
static void MaliIdentify(int flags);
static Bool MaliProbe(DriverPtr drv, int flags);
static Bool MaliPreInit(ScrnInfoPtr pScrn, int flags);
static Bool MaliScreenInit(SCREEN_INIT_ARGS_DECL);
static Bool MaliCloseScreen(CLOSE_SCREEN_ARGS_DECL);
static Bool MaliHWSwitchMode(SWITCH_MODE_ARGS_DECL);
static void MaliHWAdjustFrame(ADJUST_FRAME_ARGS_DECL);
static Bool MaliHWEnterVT(VT_FUNC_ARGS_DECL);
static void MaliHWLeaveVT(VT_FUNC_ARGS_DECL);
static ModeStatus MaliHWValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags);
static int pix24bpp = 0;
static int malihwPrivateIndex = -1;
static int global_drm_fd = -1;
_X_EXPORT DriverRec MALI =
{
MALI_VERSION,
MALI_DRIVER_NAME,
MaliIdentify,
MaliProbe,
MaliAvailableOptions,
NULL,
0,
NULL,
NULL,
NULL,
};
/ Supported "chipsets" /
static SymTabRec MaliChipsets[] =
{
{ 0, "mali" },
{ -1, NULL }
};
/ Supported options /
typedef enum
{
OPTION_DRI2,
OPTION_DRI2_PAGE_FLIP,
OPTION_DRI2_WAIT_VSYNC,
OPTION_UMP_CACHED,
OPTION_UMP_LOCK,
} FBDevOpts;
static const OptionInfoRec MaliOptions[] =
{
{ OPTION_DRI2, "DRI2", OPTV_BOOLEAN, {0}, TRUE },
{ OPTION_DRI2_PAGE_FLIP, "DRI2_PAGE_FLIP", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_DRI2_WAIT_VSYNC, "DRI2_WAIT_VSYNC", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_UMP_CACHED, "UMP_CACHED", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_UMP_LOCK, "UMP_LOCK", OPTV_BOOLEAN, {0}, FALSE },
{ -1, NULL, OPTV_NONE, {0}, FALSE }
};
#ifdef XFree86LOADER
#ifndef PACKAGE_VERSION_MAJOR
#define PACKAGE_VERSION_MAJOR 0
#endif
#ifndef PACKAGE_VERSION_MINOR
#define PACKAGE_VERSION_MINOR 1
#endif
#ifndef PACKAGE_VERSION_PATCHLEVEL
#define PACKAGE_VERSION_PATCHLEVEL 1
#endif
MODULESETUPPROTO(MaliSetup);
static XF86ModuleVersionInfo MaliVersRec =
{
"mali",
MODULEVENDORSTRING,
MODINFOSTRING1,
MODINFOSTRING2,
XORG_VERSION_CURRENT,
PACKAGE_VERSION_MAJOR, PACKAGE_VERSION_MINOR, PACKAGE_VERSION_PATCHLEVEL,
ABI_CLASS_VIDEODRV,
ABI_VIDEODRV_VERSION,
NULL,
{0, 0, 0, 0}
};
计算n的n次方:
#include<stdioh>
int a[300000],a1[300000];b[100];
void fwa()
{
int i=0;
for(i=0;i<300000;i++)
a[i]=-1;
}
void fwa1()
{
int i=0;
for(i=0;i<300000;i++)
a1[i]=-1;
}
void fwb()
{
int i=0;
for(i=0;i<100;i++)
b[i]=-1;
}
void fl(int x)
{
int i=0;
fwb();
if(x==0)
b[i]=0;
else
for(i=0;x!=0;i++)
{
b[i]=x%10;
x=x/10;
}
}
main()
{
int i=0,j=0,n,m=0,k;
for(;;)
{
fwa();
fwa1();
printf("请输入n值:\n");
scanf("%d",&n);
fl(n);
for(i=0;b[i]!=-1;i++)
a[i]=b[i];
for(m=0;m<n-1;m++)
{
for(i=0;a[i]!=-1;i++)
{
a1[i]=a[i]n;
}
fwa();
for(i=0;a1[i]!=-1;i++)
{
fl(a1[i]);
for(j=0;b[j]!=-1;j++)
{
if(a[i+j]!=-1)
{
if(b[j]+a[i+j]<10)
a[i+j]=b[j]+a[i+j];
else
{
k=b[j]+a[i+j];
a[i+j]=k%10;
if(a[i+j+1]!=-1)
a[i+j+1]=1+a[i+j+1];
else
a[i+j+1]=1+a[i+j+1]+1;
}
}
else
{
if(b[j]+a[i+j]<10)
a[i+j]=b[j]+a[i+j]+1;
else
{
k=b[j]+a[i+j];
a[i+j]=k%10+1;
if(a[i+j+1]!=-1)
a[i+j+1]=1+a[i+j+1];
else
a[i+j+1]=1+a[i+j+1]+1;
}
}
}
}
}
for(i=0;a[i]!=-1;i++);
j=i;
for(i--;i>=0;i--)
{
printf("%d",a[i]);
}
printf("\n一共%d位\n",j);
}
}
scanf判断输入字符串时,终止符有“空格”和“回车”两种。Hello“空格”word,只录入Hello。 scanf("%s",s); i=0; for(;i!=sizeof(s);++i) if(s[i]=='\0') { s[i]=" ";/空格/ bresk;} scanf("%s",s[i+一]); //接在后面写 尝试一下,方法比较笨
以上就是关于急需100行左右的C语言程序全部的内容,包括:急需100行左右的C语言程序、程序员写程序时经常出错吗我刚学c,写的100行左右代码就有好几个问题上万行的代码那是怎么写的啊、随便给个100行左右的java小程序,就给分,作业,急等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)