English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

1.寫一個程式能讀入一串字將其字元數算出來且若有小寫字元將其轉成大小字元??



2利用hbhit.getch.getche.gets.getchan等函數中的兩個函數完成it's only for test 字串不停顯示只再案enter時能節訴程式~其他無效


拜託了我很急.................

2007-01-04 17:04:49 · 2 個解答 · 發問者 WENCHENG 1 in 電腦與網際網路 程式設計

2 個解答

建議你以後一題一題問,比較有人會回答


第一題


#include
#include

using namespace std;

int main(int argc, char *argv[])
{
char a[1000]={0}; //限制字數
scanf("%s", a);
strupr(a); //轉成大寫
printf ("字元:%s\\n長度:%d\\n",a,strlen(a));
system("PAUSE");
return EXIT_SUCCESS;
}
----------------------------------------------------------


第二題
----------------------------------------------------------
#include
#include
#include

using namespace std;

int main(int argc, char *argv[])
{
int exit_prog=0;
do{

printf("it's only for test\\n");
if (kbhit()) if (getch()==13) exit_prog=1; //用了二個你指定的函數 ,13就是enter鍵盤值

}while (exit_prog==0);

system("PAUSE");
return EXIT_SUCCESS;
}

2007-01-04 18:47:19 · answer #1 · answered by TWSOFT 3 · 0 0


第一題
//Power by Microsoft Visual Studio 2005
//可以使用 Dev-C++ 編譯此程式
#include
#include
#include
int main(int argc, char *argv[]){
//=====START=====//
char STRING[]="BOOK book";
strlwr(STRING);
strupr(STRING+4);
printf("轉換後 %s\\n",STRING);
//=====END=====//
system("PAUSE");
return 0;
}
第二題 ( 原始碼取自 M$VS2005 說明文件 )
#include
#include

int main( void )
{
/* Display message until key is pressed. */
while( !_kbhit() )
_cputs( "Hit me!! " );

/* Use _getch to throw key away. */
printf( "\\nKey struck was '%c'\\n", _getch() );
}

2007-01-04 18:34:58 · answer #2 · answered by Big_John-tw 7 · 0 0

fedest.com, questions and answers