>即時新聞-熱門

2008年8月7日星期四

VC++ - 字串函數

#include<iostream>
#include<string>
using namespace std;

void main()
{
string st1,st2,st3,st4,st5,st6;
int ap;
st1="大家好第一次";
st2="大家好二次";
st4="今天";
st5="快樂";
st6="is";

st3.assign(st1);
cout << "st3後的內容為:" << st3 << endl;
st4.append(st5);
cout << "st4後的內容為:" << st4 << endl;
st1.compare(st2) 
cout << st1內容 << ST1 << endl;

}

VC++ - 字串引用

#include<iostream>
#include<string>
using namespace std;
void main()
{
string st1("宣告字串變數");
string st2(st1);
string st3(st2,0,4); 
cout << "st1=" << st1 << endl;
cout << "st2=" << st2 << endl;
cout << "st3=" << st3 << endl;

}

VC++ --字串

#include<iostream>
#include<ctype.h>
using namespace std;
void main()
{
char my_char;
cout << "請輸入一個字元:" << endl;;
cout << "==============================================" << endl;
cin >> my_char;
if( isalpha(my_char) != 0)
cout << "您輸入的字元是英文字母" << endl;
if (isspace(my_char) != 0)
cout << "您輸入的字元空白字元" << endl;
if (ispunct(my_char) != 0)
cout << "您輸入的字元是標點符號字元" << endl;
if (islower(my_char) != 0)
cout << "您輸入的字元是小寫字元" << endl;
cout << "==============================================" << endl;
}

VC++ - 字串

函數 用途 函數 用途
iscntrl 控制字元 isspace 空白字元
isalpha 英文字母 islower 小寫字元
isdigit 十進位字元 isupper 大寫字元
isxdigit 十六進位字元 isalunum 英文字母或數字
ispunct 標點符號字元 isgraph 可顯示字元
Isprint 可列印字元 tolower 轉小寫字元
toupper 轉大寫字元

2008年8月6日星期三

VC++ - include

注意事項:
使用#include , 不可使用#include
在插入C++ 新型標題檔後(例如:#include ),必須加入(using namespace std;)敘述,來宣告程式中的函數是使用新型的C++ 型態標題檔,而不是使用舊型的C型態標題檔。

妹咕旦生(5)

人總是在失意時 , 才會想到得意時 . 阿咪說道 : 今天我可以下床了 , 帶我去會客
早上剛醒來 , 我的生理時鐘告訴我可以再睡一下 , 但是我的心裡時間郤說 , 快去看妹咕
如果在從前生理和心理博鬥時, 通常生理一定戰勝
現在的我已無任何三度空間去思考生理和心理博鬥結果 , 因為它的內容只有 妹咕
我一句話都沒說 , 就牽著阿咪的手 , 偷偷離開宏恩[婦產科 , 台北仁愛路上]
手一揮 , 司機 : 馬階 民生東路
帶著罪過的心 , 帶著受害者 , 我這個加害人 , 第二次走到加護病房 , 輕聲細語[這不是我的風格]
深怕大聲引起護士不悅 , 就不讓我見 我的至愛-- 妹咕 , 何況我帶了 另一個最愛 - 阿咪

出來了 , 加護病房的護士小姐走出來了 , 她沒有讓我失望 ,護士小姐這樣呼叫 : 楊欣潔的家屬 , 阿咪我和手握的更緊了 [阿咪比我有力多了] , 立即向前說道 : 我是 , 護士小姐說道 : 欣潔目前尚未脫離險境 ,
目前主治醫生 , 給她施打抗生素 , 類固

CINDY的2個問題

CINDY的2個問題1.我想做產品的一些文字介紹在預留影像的旁邊,要怎麼做可以我滑鼠移動介紹也會跟著換? 2.以及預留影像只能留一張圖嗎?我可以留2.3張嗎?譬如我想秀出正反面側面之類的

回答問題1
文字要做到移動換圖 , 請將文字以圖片展現 , 做法和圖片一樣
回答問題2
預留本就可以多點項目
只要其名稱不同就OK

VC++ - 體重程式

#include <iostream>

using namespace std;

void main()
{
int i,j,x;
double k;

cout<<"輸入身高:";
cin>>i;
cout<<"輸入體重:";
cin>>j;

k=i*i*22/10000;
x=(int)k;

if(x<j)
cout<<"太重"<<endl;
else
cout<<"可接受"<<endl;



}

VC++ - 三元條件

#include <iostream>
using namespace std;
void main()
{
 int key_in , level;
    
 cout<<"請輸入您的年齡:";
 cin >> key_in;
 cout<<endl;
level=(key_in>50)?100:10;
 
    cout<<"您太老了"<<level;

}

VC++ - SWITCH

#include <iostream>
using namespace std;
void main()
{
 int key_in , level;
    
 cout<<"請輸入您的年齡:";
 cin >> key_in;
 cout<<endl;
level=(int)key_in/10;
 switch(level){
 case 5:
      cout<<"老人家";
  break;
 case 4:
      cout<<"小人家";
  break;
 case 3:
      cout<<"老大人家";
  break;
 case 2:
      cout<<"老人家";
  break;

 default:
    cout<<"不是人";

}}

VC++ - IF

#include <iostream>
using namespace std;
void main()
{
 int key_in;
    
 cout<<"請輸入您的年齡:";
 cin >> key_in;
 cout<<endl;

   if(key_in>=60)
      cout<<"老人家";
   else
    cout<<"年青人";

}

2008年8月5日星期二

VC++ - 一維陣列

#include<iostream>       
using namespace std;

void main()
{
const int Size=4;
int int_array[Size]={10,20};
char ch_array[4]={'a','b','c'};
double db_array[4]={11.13,12.12};
int MY_array[10];
int NOFIX_array[]={1,2,3,4};
int i,MY_loop;
MY_loop = 2;
for(i=0;i<MY_loop;i++){
MY_array [i]=i;
cout << "array[" << i << "]=" << MY_array[i] << endl;
cout << "int_array[" << i << "]=" << int_array[i] << endl; 
cout << "ch_array[" << i << "]=" << ch_array[i] << endl;
cout << "db_array[" << i << "]=" << db_array[i] << endl;
cout << "NOFIX_array[" << i << "]=" << NOFIX_array[i] << endl;
}
}

VC++ - 多重執行

#include<iostream>       
using namespace std;

#define MY_WEEK 7

void main()
{
#if MY_WEEK ==1 
#define Str "週日"
#elif MY_WEEK  ==2
#define Str "週一"
#elif MY_WEEK  == 3
#define Str "週二"
#elif MY_WEEK  == 4
#define Str "週三"
#elif MY_WEEK  == 5
#define Str "週四"
#elif MY_WEEK  == 6
#define Str "週五"
#elSE
#define Str "週六"

#endif
cout << "現在為:" << Str << endl;
}

VC++ -  引入檔案

myhelp.h的內容

#define my_birth 10
#define my_name "ALEX"


#include<iostream>      
using namespace std;

#include "myhelp.h"  
void main()
{
cout << "現在是 " << my_birth <<" 月" << endl;
cout << "我是:" << my_name << endl;
}

VC++ - 巨集

#include<iostream>       
using namespace std;
#define my_Sum a+b
#define my_Name "ALEX"
void main()
{
int a,b;
a=10;
b=20;
cout << "a+b=" << my_Sum << endl;
cout << "名字:" << my_Name << endl;
#undef my_Name
#define my_Name "lisa"
cout << "名字:" << my_Name << endl;
}

 
妹咕數位學園歡迎網友們來信指教 妹咕信箱