• 首頁
  • 產品
    • 所有產品
    • 歐維斯瀏覽器
  • 關於我們
facebook Email

歐維斯福利設

Always Security Blog


#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
    cout<<"Hello World!"<<endl;
    system("pause");
    return 0;
}
Share
Tweet
Share
No 意見
/*編譯成test.exe後,假設存放在:
D:\cpp files\test
打開命令提示字元(按下win + R,打cmd),輸入:
D:\cpp files\test\test.exe 87
*/
#include <iostream>
using namespace std;
int main(int argc,char *argv[])
{
  int i;
  cout<<"argc = "<<argc<<endl;
  for(i=0;i<argc;i++)
    cout<<argv[i]<<endl;
  return 0;
}
Share
Tweet
Share
No 意見

#include <iostream>
#include <cstdlib>
#include <ctime>
#define SIZE 20
using namespace std;
int search(int [ ],int,int,int);
int main(void)
{
    int i,a[SIZE],from=0,key;
    srand(time(NULL));  //亂數產生陣列元素值
    for(i=0;i<SIZE;i++)
      a[i] = rand( ) % 10 + 1;  
    cout<<"請輸入欲搜尋的值(1~10)";
    cin>>key;
    while(from < SIZE) {
      int ans;
      ans = search(a,from,SIZE,key);
      if(ans == -1) {
        if(!from)    
          cout<<key<<" not found\n";
        break;
      } else {
            cout<<key<<" found at a["<<ans<<"] = "<<a[ans]<<endl;
            from = ans + 1;
      }
    }
    return 0;
}
int search(int a[ ],int from,int size,int key)
{
   int i;
   for(i=from;i<size;i++)
     if(a[i] == key)
       return i;
   return -1;      
}
Share
Tweet
Share
No 意見

#include <iostream>
using namespace std;
void vset(int,int);
void rset(int*,int);
int main(void)
{
  int x=0,*p;           //宣告變數x及整數指標p
  p = &x;             //取得變數x的位址(將p指向x)
  vset(x,1);            
  cout<<"x = "<<x;
  rset(p,1);            //將指標當作引數來傳遞進函式
  cout<<"x = "<<x;
  return 0;
}
void vset(int x,int y)
{
  x = y;
}
void rset(int *p,int y)
{
  *p = y;              //間接存取變數x
}
Share
Tweet
Share
No 意見

#include <iostream>
using namespace std;
int Mystrcmp(char *,char *);
int main(void)
{
  int result;
  char word1[ ] = "I like C";    //字串1
  char word2[ ] = "This is fun";  //字串2
  result = Mystrcmp(word1,word2);
  if(!result)
    cout<<"word1 equal word2\n";
  else
    cout<<"word1 does not equal word2\n";
  return 0;
}
int Mystrcmp(char *str1,char *str2)
{
  int i;
  for(i=0;!(*(str1+i) == '\0' && *(str2+i) == '\0'); i++)
    if(*(str1+i) != *(str2+i)) return -1;
  return 0;
}
Share
Tweet
Share
No 意見

#include <iostream>
using namespace std;
void Mystrcpy(char *,char *);
int main(void)
{
  int result;
  char word1[ ] = "I like C";
  char word2[ ] = "This is fun";
  Mystrcpy(word1,word2);
  cout<<"word2 = "<<word2<<endl;
  return 0;
}
void Mystrcpy(char *str1,char *str2)
{
  int i;
  for(i=0;*(str1+i)!='\0';i++)
  *(str2+i) = *(str1+i);
  *(str2 + i) = '\0';
}
Share
Tweet
Share
1 意見

#include <iostream>
#include <fstream>
using namespace std;
char* encode(char*);
char* decode(char*);
int main(void)
{
  char ch,str[80];
  cout<<"請輸入字串:";
  gets(str);
  cout<<"您要 1)加密 2)解密 :";
  cin>>ch;
  if(ch == '1') {
    cout<<"After encode : ";
    cout<<encode(str);
  } else if (ch == '2') {
    cout<<"After decode :";
    cout<<decode(str);
  } else
    cout<<"Unknown input";
  return 0;
}
char* encode(char *str)
{
      char *r=str;
      while(*str) {
        *str = *str + 13;
        str++;
      }  
      return r;
}
char* decode(char *str)
{
      char *r=str;
      while(*str) {
        *str = *str - 13;
        str++;
      }
      return r;
}
Share
Tweet
Share
No 意見
較新的文章
較舊的文章

FACEBOOK

歐維斯福利社

熱門文章

  • 【Windows 全攻略】各版本Windows ISO 下載
  • 【超狂】微軟各產品KMS序號大全!!!
  • 【電腦秘笈】如何下載YouTube的影片?只需兩個步驟!!!(不用安裝軟體)
  • 【c++範例】輸出、入變數的值
  • 最詳盡的CMD命令大全

標籤

C語言範例 C++ C++範例 駭客教學 電腦秘笈 Windows Windows高手秘笈 資安Q&A 病毒 C語言 程式設計 免費軟體 新鮮事 木馬程式 C語言病毒 Python SQL 檔案下載 硬體 Tor 序號大全 沙盒 測試樣本 登錄檔操作 GTA5 信息蒐集 外掛 底層 影音相關軟體 遊戲

開站以來瀏覽量

文章存檔

  • 7月 2019 (1)
  • 5月 2019 (1)
  • 12月 2018 (3)
  • 8月 2018 (2)
  • 7月 2018 (1)
  • 6月 2018 (1)
  • 4月 2018 (3)
  • 3月 2018 (4)
  • 2月 2018 (2)
  • 12月 2017 (2)
  • 11月 2017 (4)
  • 10月 2017 (3)
  • 9月 2017 (18)
  • 8月 2017 (28)
  • 7月 2017 (7)
  • 6月 2017 (3)
  • 5月 2017 (3)

歐維斯版權所有|未經許可禁止轉載