![]()  | 
		
			
  | 	
	
	
		
		|||||||
| 論壇說明 | 
| 
				歡迎您來到『史萊姆論壇』  ^___^ 您目前正以訪客的身份瀏覽本論壇,訪客所擁有的權限將受到限制,您可以瀏覽本論壇大部份的版區與文章,但您將無法參與任何討論或是使用私人訊息與其他會員交流。若您希望擁有完整的使用權限,請註冊成為我們的一份子,註冊的程序十分簡單、快速,而且最重要的是--註冊是完全免費的! 請點擊這裡:『註冊成為我們的一份子!』  | 
		
     
![]()  | 
    
    
| 
         | 
    主題工具 | 顯示模式 | 
| 
			
			 | 
		#1 | 
| 
			
			 註冊會員 
			
			
			
			
			
			
			 | 
	
	
	
		
		
			
			 請問各位高手們! 
		
		
		
	若想用c++的語法寫出一到密碼鎖的程式!(陣列與字串) 也就是大概來說->例如:先設一定4位數字為密碼 寫出一套程式~ 只能讓輸入密碼者輸入3次密碼! 若第3次沒還有成功的話! 程式即顯示"密碼已鎖" 也就是已經沒辦法解開的意思! 大概類似提款卡的一套程式! 希望各位高手朋友們有興趣的話可以一起討論喔! 我使用的是這套c++軟體->Dev C++是免費軟體可從http://www.bloodshed.net/devcpp.html 下載 最新的版本與相關的資源  | 
| 
		 | 
	
	
	
		
	
	 
		送花文章: 3,
		
			
		 
	
 
	
		
	
				 
		
		
		
		
		
		
			
		
		
		
		
		
			
					
						
					
			
		
		
		
		
		
			
				
			
		
		
		
	 | 
| 
			
			 | 
		#2 (permalink) | 
| 
			
			 註冊會員 
			
			
			
			
			
			
			 | 
	
	
	
		
		
			
			 #include<iostream> 
		
		
		
	using namespace std; int main() { bool isMatch = false; string userInput, pass = "defaultpass"; int counter = 0; do{ cin >> userInput; counter ++: isMatch = (userInput == pass); } while( !isMatch && (counter <= 3)); if(!isMatch) cout << "密碼已鎖" << endl; return 0; } :P should be right, but didn't check to make sure if correct  | 
| 
		 | 
	
	
	
		
	
	 
		送花文章: 1,
		
			
		 
	
 
	
		
	
				 
		
		
		
		
		
		
			
		
		
		
		
		
		
		
		
		
			
				
						
				
			
		
		
		
	 | 
| 
			
			 | 
		#5 (permalink) | ||
| 
			
			 註冊會員 
			
			
			
			
			
			
			 | 
	
	
	
		
		
			
			 引用: 
	
 引用: 
	
 no error messages were generated, so it should be correct this time, ------------------------------------------------ #include<iostream> using namespace std; int main() { bool isMatch = false; string userInput, pass = "defaultpass"; int counter = 1; cout << "Please enter your password" << endl; cin >> userInput; for(int counter = 1; counter <=3 && !(userInput == pass); counter++) { cout << "Please try again" << endl; cin >> userInput; } if(!isMatch) cout << "pass locked" << endl; return 0; }  | 
||
| 
		 | 
	
	
	
		
	
	 
		送花文章: 1,
		
			
		 
	
 
	
		
	
				 
		
		
		
		
		
		
			
		
		
		
		
		
		
		
		
		
			
				
						
				
			
		
		
		
	 |