My First Article

     作为一个IT从业者,我们都应该深知学习笔记的重要性,生活中学习的点点滴滴认知,成就了技术的提升,然后一味的“我认为简单好记”往往忽略了好记性不如烂笔头的真知。非常遗憾的告诉自己,惰性左右了我这么些年,个人2015年就开通了CSDN,那时候有所学有所识全都是脑海强记或者一时兴起地浅浅实践,并未开始做任何形式的笔记,也许该做点什么来记录一下,甚至有时间来回味一下那些还未失去的学习记忆,以及事业初始学习的心路历程。

       该博客的文章笔记从2016年的有道云笔记开始逐篇迁移,其中很多知识点不乏别人的原创博客,如有冒犯请及时邮件通知加入原创说明(endcy#qq.com)

阅读更多

This is my My first math programm....??

06-26

//---------------------------------------------------------------------------rnrn#include rn#pragma hdrstoprn#include "math.h"rn#include "MathSys.h"rn#include "stdio.h"rn#include "vcl/inifiles.hpp" //-------------------------------INIfile Is OK!rn//---------------------------------------------------------------------------rn#pragma package(smart_init)rn#pragma resource "*.dfm"rnTForm1 *Form1;rnint pt=1;rn//---------------------------------------------------------------------------rn__fastcall TForm1::TForm1(TComponent* Owner)rn : TForm(Owner)rnrnrn//---------------------------------------------------------------------------rnvoid __fastcall TForm1::FormCreate(TObject *Sender)rnrn OnWrite0(N,N);rn HangLieShi=1;rnrn//---------------------------------------------------------------------------rnvoid TForm1::OnWrite0(int i,int j)rnrn String S;rn for(int i0=1;i0<=i;i0++)rn S.sprintf("%d",i0);StringGrid1->Cells[0][i0]=S;rn for(int i0=1;i0<=j;i0++)rn S.sprintf("%d",i0);StringGrid1->Cells[i0][0]=S;rnrnrnrnvoid __fastcall TForm1::Edit2KeyDown(TObject *Sender, WORD &Key,rn TShiftState Shift)rnrn if(Key==13)rn rn if(Edit1->Text!=""&&Edit2->Text!="")rn rn if(StrToInt(Edit1->Text)<1||StrToInt(Edit2->Text)<1||StrToInt(Edit1->Text)>40||StrToInt(Edit2->Text)>40)rn MessageBox(Handle,"Please Check The Number(1~40)","Note!",0);return ; rnrn h=StrToInt(Edit1->Text);l=StrToInt(Edit2->Text);rnrn StringGrid1->ColCount=l+1;rn StringGrid1->RowCount=h+1;rn OnWrite0(h+1,l+1);rn rn else MessageBox(Handle,"Please Input the ColNumber or LieNumber","Please!",0);rn rnrn//---------------------------------------------------------------------------rnrnvoid __fastcall TForm1::Edit1KeyDown(TObject *Sender, WORD &Key,rn TShiftState Shift)rnrnrn if(Key==13)rn rn if(Edit1->Text!=""&&Edit2->Text!="")rn rn if(StrToInt(Edit1->Text)<1||StrToInt(Edit2->Text)<1||StrToInt(Edit1->Text)>40||StrToInt(Edit2->Text)>40)rn MessageBox(Handle,"Please Check The Number(1~40)","Note!",0);return ; rnrn h=StrToInt(Edit1->Text);l=StrToInt(Edit2->Text);rnrn StringGrid1->ColCount=l+1;rn StringGrid1->RowCount=h+1;rn OnWrite0(h+1,l+1);rn rn else MessageBox(Handle,"Please Input the ColNumber or LieNumber","Please!",0);rn rnrnrn//---------------------------------------------------------------------------rnbool TForm1::OnRead0(int p)rnrnif(p==1)rnrn for(int i=0;iCells[j+1][i+1]!="") A[i][j]=StrToFloat(StringGrid1->Cells[j+1][i+1]);rn else return false;rn rn return true;rnrnelsernreturn true;rnrnrnrnvoid __fastcall TForm1::DieDai1Click(TObject *Sender)rnrn if(PanDuan1(1))rn rn if(OnRead0(1))rn float Sovle[N][3*N];rn float D;rn MessageBox(Handle,"Please Confirm 严格主对角占优!","OK",0);rn AnsiString S;rn if(InputQuery("Input The Start point","The Start Point:",S))rn for(int i=0;iD&&p<3*N-1);rnrn StringGrid1->ColCount=l+2;rn StringGrid1->RowCount=h+3;rn for(int i=0;iCells[i+1][h+2]=FloatToStr(Sovle[i][p]);rnrn rn if(p!=3*N-1)rn StringGrid1->Cells[l+1][h+2]=IntToStr(p);rn else StringGrid1->Cells[l+1][h+2]="No Sovle";rnrn rn rn rn else MessageBox(Handle,"Please Finish The Data!","Check",0);return;rn rn else MessageBox(Handle,"No SOVEL or No Def HANG and LIE!","Check",0);rnrn//---------------------------------------------------------------------------rnbool TForm1::PanDuan1(int i)rn if(i==1)rn return h==l-1?true:false;rn if(i==2)rn return h==l?true:false;rn return true;rnrnfloat TForm1::MAX0(float Z[N][3*N],int q)rnrn float crease=fabs(Z[0][q]-Z[0][q-1]);rn for(int i0=0;i0=i;j--)rn if(A[i][i]!=0) A[q][j]=A[q][j]-A[i][j]/A[i][i]*A[ q][i];rn else TiaoZhen(i+1);return;rnrnrn rn if(Check(h)==0)rn rn for(int i=h-1;i>=0;i--)rn rn for(int q=i-1;q>=0;q--)rn for(int j=h+l-1;j>=i;j--)rn if(A[i][i]!=0) A[q][j]=A[q][j]-A[i][j]/A[i][i]*A[ q][i];rn else TiaoZhen(i+1);return;rn rnrn for(int i=0;iColCount=l+1+h;rn StringGrid1->RowCount=h+2+h;rn for(int i=0;iCells[j+1][i+h+2]=FloatToStr(A[i][j]);rn rn else MessageBox(Handle,"No Sovler","Notes",0);HangLieShi=0;return;rn rn else TiaoZhen(Check(h));return;rn rn else MessageBox(Handle,"Please Finish The Data!","Check",0);return;rn rn else MessageBox(Handle,"No SOVEL or No Def HANG and LIE!","Check",0);rnrnrnrn//---------------------------------------------------------------------------rnrnvoid __fastcall TForm1::Reflash1Click(TObject *Sender)rnrn Edit1->Text="";rn Edit2->Text="";rn StringGrid1->ColCount=N+1;rn StringGrid1->RowCount=N+1;rn for(int i=0;iCells[j][i]="";rnrn pt=1;rn OnWrite0(N,N);rn StringGrid1->Refresh();rnrn//---------------------------------------------------------------------------rnint TForm1::Check(int t)rnrn for(int i=0;iCells[i][1];StringGrid1->Cells[i][1]=StringGrid1->Cells[i][pp];rn StringGrid1->Cells[i][pp]=S;rn elsern for(int i=1;i<=l;i++)rn S=StringGrid1->Cells[i][pp];StringGrid1->Cells[i][pp]=StringGrid1->Cells[i][h];rn StringGrid1->Cells[i][h]=S;rn XiaoQu1Click(this);rnrnvoid __fastcall TForm1::NiZhen1Click(TObject *Sender)rnrnrn MessageBox(Handle,"Please Read the Qquention!","Check",0);return;rnrnrnrn//---------------------------------------------------------------------------rnvoid TForm1::Refresh()rnrn for(int i=0;iFilter="TXT Files(*.TXT)|*.txt";rn if(SaveDialog1->Execute())rn rn FILE *fp;rn float temp;rn fp=fopen((SaveDialog1->FileName+".TXT").c_str(),"w");rn if(h==0&&l==0)MessageBox(Handle,"The file is ampty!","Warnin" ,1);fclose(fp);return;rn fprintf(fp,"%d\n",h);rn fprintf(fp,"%d\n",l);rn for(int i=0;iCells[j+1][i+1]);if(j!=l-1) fprintf(fp,"%f ",temp);else fprintf(fp,"%f\n",temp);rn fclose(fp);rn rnrn//---------------------------------------------------------------------------rnrnvoid __fastcall TForm1::Open1Click(TObject *Sender)rnrn OpenDialog1->Filter="TXT Files(*.TXT)|*.txt";rn if(OpenDialog1->Execute())rn rn FILE *fp;rn float ftmp;rn int itmp1,itmp2,i,j;rn fp=fopen(OpenDialog1->FileName.c_str(),"r");rn if(!fscanf(fp,"%d",&itmp1)||(!fscanf(fp,"%d",&itmp2))) MessageBox(Handle,"The data File is read error!","Warning",1);fclose(fp);return;rn h=itmp1;rn l=itmp2;rn Edit1->Text=IntToStr(itmp1);rn Edit2->Text=IntToStr(itmp2);rnrn StringGrid1->ColCount=itmp2+1;rn StringGrid1->RowCount=itmp1+1;rn OnWrite0(itmp1,itmp2);rn for(i=0;iCells[j+1][i+1]=FloatToStr(ftmp);rn else MessageBox(Handle,"The data is not Complete!","Waring!",1);fclose(fp);return;rn rnrn fclose(fp);rn rnrn//---------------------------------------------------------------------------rnrnvoid __fastcall TForm1::StuZongHeAnysys1Click(TObject *Sender)rnrn //Refresh();rn if(OnRead0(pt))rn AnsiString S="5";rn int Head_del,Last_del;rn // float temp[N][N];rn PaiXu(h,l,true);rn if(InputQuery("Input the Head_DEL Number","The Head_DEL Number(5)",S))rn Head_del=StrToInt(S);rn else Head_del=5;rn if(InputQuery("Input the Last_DEL Number","The Last_DEL Number(5)",S))rn Last_del=StrToInt(S);rn else Last_del=5;rn for(int i=0;iCells[j+1][i+1]=FloatToStr(tmp[i][j]);rn StringGrid1->RowCount=h+3;rn for(int t=1;t<=l;t++)rn StringGrid1->Cells[t][h+2]=FloatToStr(Stu_Aver(t-1,Head_del,Last_del,true));rnrn pt++;rn rn else MessageBox(Handle,"Please Complete the data or the data is not match!","Warning!" ,1);return;rnrnrn//---------------------------------------------------------------------------rnvoid TForm1::PaiXu(int i,int j,bool mode)rnrnrn float Temp,p;rn Swap();rn if(mode)rn rn for(int j0=0;j0Cells[j+1][i+1]=FloatToStr(tmp[i][j]);rn StringGrid1->ColCount=l+3;rn for(int t=1;t<=h;t++)rn StringGrid1->Cells[l+2][t]=FloatToStr(Stu_Aver(t-1,Head_del,Last_del,false));rnrn pt++;rn rn else MessageBox(Handle,"Please Complete the data or the data is not match!","Warning!" ,1);return;rnrnrnrn//---------------------------------------------------------------------------rnvoid TForm1::Swap()rnrnrn for(int i=0;iFilter="INI Files(*.INI)|*.ini";rn if(SaveDialog1->Execute())rn rnrn TIniFile *IniSave=new TIniFile(SaveDialog1->FileName+".ini");rn IniSave->WriteString("Col_Row","Row",IntToStr(h));rn IniSave->WriteString("Col_Row","Col",IntToStr(l));rn for(int i=0;iWriteString("DATA","A["+IntToStr(i)+","+IntToStr(j)+"]",StringGrid1->Cells[j+1][i+1]);rn delete IniSave;rn rnrnrn//---------------------------------------------------------------------------rnrnvoid __fastcall TForm1::Openini1Click(TObject *Sender)rnrn OpenDialog1->Filter="INI Files(*.INI)|*.ini";rn if(OpenDialog1->Execute())rn rn TIniFile *IniOpen=new TIniFile(OpenDialog1->FileName);rn h=StrToInt(IniOpen->ReadString("Col_Row","Row","0"));rn l=StrToInt(IniOpen->ReadString("Col_Row","Col","0"));rn Edit1->Text=IniOpen->ReadString("Col_Row","Row","0");rn Edit2->Text=IniOpen->ReadString("Col_Row","Col","0");rn StringGrid1->RowCount=h+1;rn StringGrid1->ColCount=l+1;rn OnWrite0(h,l);rn for(int i=0;iCells[j+1][i+1]=IniOpen->ReadString("DATA","A["+IntToStr(i)+","+IntToStr(j)+"]","0");rn delete IniOpen;rn rnrnrn//---------------------------------------------------------------------------rnrnBut there are some mistakes!Please give me some advices!thinks!

Article

09-28

Problem DescriptionnAs the term is going to end, DRD begins to write his final article.nnDRD uses the famous Macrohard's software, World, to write his article. Unfortunately this software is rather unstable, and it always crashes. DRD needs to write n characters in his article. He can press a key to input a character at time i+0.1, where i is an integer equal or greater than 0. But at every time i−0.1 for integer i strictly greater than 0, World might crash with probability p and DRD loses his work, so he maybe has to restart from his latest saved article. To prevent write it again and again, DRD can press Ctrl-S to save his document at time i. Due to the strange keyboard DRD uses, to press Ctrl-S he needs to press x characters. If DRD has input his total article, he has to press Ctrl-S to save the document. nnSince World crashes too often, now he is asking his friend ATM for the optimal strategy to input his article. A strategy is measured by its expectation keys DRD needs to press. nnNote that DRD can press a key at fast enough speed. n nnInputnFirst line: an positive integer 0≤T≤20 indicating the number of cases.nNext T lines: each line has a positive integer n≤105, a positive real 0.1≤p≤0.9, and a positive integer x≤100.n nnOutputnFor each test case: output ''Case #k: ans'' (without quotes), where k is the number of the test cases, and ans is the expectation of keys of the optimal strategy.nYour answer is considered correct if and only if the absolute error or the relative error is smaller than 10−6. n nnSample Inputn2n1 0.5 2n2 0.4 2n nnSample OutputnCase #1: 4.000000nCase #2: 6.444444n

没有更多推荐了,返回首页