寶馬測試(C++實現),寶馬測試實現

來源:互聯網
上載者:User

寶馬測試(C++實現),寶馬測試實現


     測試目的:對編輯器放大,縮小效能測試。

     測試資源:一匹寶馬。 

     測試結果:良好。






      實現方法:通過調用本地儲存的寶馬檔案,逐字逐行的顯示在編輯器中,並放大,縮小。對不同的符號進行上色處理。


1. 寶馬檔案

     

       

{/*LOOKBMW                               _(\_/)                              ,((((^`\                            ((((  (6 \                           ,((((( ,    \      ,,,_              ,(((((  /"._  ,`,     ((((\\ ,...       ,((((   /    `-.-'     )))  ;'    `"'"'""((((   (          (((  /            (((      \     )) |                      |    ((  |        .       '     |    ))  \     _ '      `t   ,.')    (   |   y;- -,-""'"-.\   \/      )   / ./  ) /         `\  \       |./   ( (           / /'       ||     \\          //'|       ||      \\       _//'||       ||       ))     |_/  ||       \_\     |_/          ||       `'"                  \_\                            `'" $—LOOKBMW*/}




2. C++實現


 A 先載入BMW檔案,在逐字逐行顯示在編輯器中。

CStdioFile LookBmwFile;CString bwmFilePath = Pack::GetConfigIniFile(_T("GlbBmwFilePath"));if(!LookBmwFile.Open(bwmFilePath, CFile::modeRead | CFile::typeText)){MessageBox(_T("Loading files Error " + bwmFilePath + ", please reinstall the software..."));}CString strBmwTxt;BOOL BwmTxtStart = false;while(LookBmwFile.ReadString(strBmwTxt)){if(BwmTxtStart){if(strBmwTxt == _T("$—LOOKBMW*/}")){break;}CString str;for(int i=0; i<strBmwTxt.GetLength(); i++){str = (strBmwTxt[i]);SendMessages(SCI_ADDTEXT, 1, (LPARAM)(LPCSTR)str);UpdateWindow();Sleep(15);}str = _T("\n");SendMessages(SCI_ADDTEXT, 1, (LPARAM)(LPCSTR)str);}if(strBmwTxt.Trim() == _T("{/*LOOKBMW")){BwmTxtStart = TRUE;}}LookBmwFile.Close();


B 設定放大的倍數,和縮小的倍數,迴圈3次。

int j=3;int i=5;while(j--){while(i--){SendMessages(SCI_ZOOMIN, 0, 0);UpdateWindow();Sleep(70);}i=15;while(i--){SendMessages(SCI_ZOOMOUT, 0, 0);UpdateWindow();Sleep(70);}i=15;}i=10;while(i--){SendMessages(SCI_ZOOMIN, 0, 0);UpdateWindow();Sleep(70);}



文/閆鑫原創 轉載請註明出處http://blog.csdn.net/yxstars/article/details/39205345



C語言 怎實現多組測試?

#include <stdio.h>
#include<string.h>
int main()
{
char c,s[100];
int i;
int letters=0,space=0,digit=0,others=0;
while(gets(s)!=NULL){
for(i=0;i<strlen(s);i++){
c=s[i];
{
if(c>='a'&&c<='z'||c>='A'&&c<='Z')
letters++;
else if(c==' ')
space++;
else if(c>='0'&&c<='9')
digit++;
else
others++;
}
}
printf("%d %d %d %d\n",letters,digit,space,others);
}
return 0;
}
 
C語言怎實現輸入多組資料測試

#include<stdio.h>
void main()
{
int n;
while(scanf("%d",&n)!=EOF,n) //或者寫成while(scanf("%d",&n)!=EOF)然後在迴圈裡加一句if(n==0)break;
{
//if(n==0)break;
if((n/10000==n%10)&&(n/1000%10==n/10%10)) //判斷迴文
printf("Yes.\n");
else
printf("No.\n");
}
}

這個代碼應該是對的,在OJ上,多組資料都是這麼處理的。

這個沒關係的,提交的時候,這樣也是對的,因為OJ系統在判斷答案的時候,輸入和輸出資料放在不同的檔案夾下面的,只要它的輸入檔案在你的程式下運行,對應的輸出檔案和他的一致,你的程式就是正確的,所以,就不需要把結果存起來。
如果你真的想那樣,那就用一個數組把答案存起來,等迴圈結束的時候,再把結果printf就行了
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.