Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > กระทู้สำหรับภาษาต่าง ๆ > ช่วยคิดโค้ด ภาษา C ใน turbo c++ หน่อยค่า ว่าจะใช้ swicth case รวมกับ loop ตัวไหนดี



ช่วยคิดโค้ด ภาษา C ใน turbo c++ หน่อยค่า ว่าจะใช้ swicth case รวมกับ loop ตัวไหนดี

 
Topic : 054552

Guest



คือให้เขียนโปรแกรมมาโปรแกรมนึงโดยมีช้อยส์ให้เลือก 5 ตัวค่ะ
คือ
1.f
2.h
3.t
4.M
5.f
9.Exit

เมื่อผู้ใช้กด 1 ให้แสดง you live in f (จนถึงหมายเลขห้า ) และแสดงเมนูให้เลือกกดได้อีก แต่ถ้าผู้ใช้กด 9 ให้จบการทำงาน



Tag : C#


Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2011-01-16 19:10:42 By : papico View : 10513 Reply : 8
 

 

No. 1

Guest


Code (C++
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>


int Check;
int Status = 0;

void main()
{

	do
	{
		clrscr();
		cout<<"\n1. f\n";
		cout<<"2. h\n";
		cout<<"3. t\n";
		cout<<"4. M\n";
		cout<<"5. f\n";
		cout<<"9. Exit\n";
		cout<<"Input Key : ";

		cin>>Check;

		switch(Check)
		{
			case	1:			cout<<"You live in f"; break;
			case	2:			cout<<"You live in h"; break;
			case	3:			cout<<"You live in t"; break;
			case	4:			cout<<"You live in M"; break;
			case	5:			cout<<"You live in f"; break;
			case	9:			exit(0); break;
		}
	}while(Status == 0);
}

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-01-30 00:44:45 By : MaxIT
 


 

No. 2

Guest


มันคือ โปรแกรม ร้านขายน้ำปั่น(ช่วยคิดหน่อยคราฟฟฟ)
คือ ผมอยากให้


Code (C++)
#include<stdio.h>
#include<conio.h>
void main(void)
{
 int user,password,total=0;
 char bath;
 clrscr();

 gotoxy(20,13);textcolor(4);cprintf("Please Add Your User And Password Thank You");      // ใส่รหัสสมาชิกเพื่อสะสมแต้ม
 gotoxy(33,15);printf("user     =");scanf("%d",&user);                                                              แต่ในสโปรแกรมไม่มี
 gotoxy(33,16);textcolor(6);printf("password =");scanf("%d",&password);
 if(user==2536,password==6352)   *****ตรงนี้ ผมอยากให้ พาสเวอร์ที่กดมา เป็น  **** อ่ะครับ เช่น ใส่  1234 มันก็จะแปลงเป็น ****
  {
   clrscr();
   gotoxy(33,18);printf("login complete\n");
   getch();
   clrscr();
   gotoxy(25,20);printf("Welcome To My Fruit Smoothies \n");
  }
 else                                                                                                 ตรงนี้คือ ถ้าผิดจะแสดงตามข้างล่าง แต่ถ้า user pass 
  {                                                                                                      ถูกจะแสดงด้านบน
   gotoxy(26,18);printf("you want use the user narmal<y>\n");
   gotoxy(40,20);getche();
   getch();
  }
 clrscr();
 int change=0;
 char choice,smoothies,glass,receive;
{
printf("< < < < : : = fruit smoothies = : : > > > > \n");
printf("1.hot fruit smoothies\n");
printf("2.cool fruit smoothies\n");
printf("3.fruit mix alcohol smoothies\n");                        ตรงนี้คือประเภทที่ต้องการจะให้เลือก มี 3ประเภท
printf("4.Exit\n");
printf("Select Menu :=");scanf("%d",&choice);
switch (choice)
{
case 1:
	clrscr();
	printf("< < : : hot fruit smoothies : : > >\n");
	printf("1.hot strawberry smoothies:= ");scanf("%d",glass);
	printf("2.hot orange smoothies:= ");scanf("%d",glass);
	printf("3.hot papaya smoothies:= ");scanf("%d",glass);
	printf("4.hot banana smoothies:= ");scanf("%d",glass);
	printf("5.hot apple smoothies:= ");scanf("%d",glass);
	printf("6.hot mango smoothies:= ");scanf("%d",glass);
	printf("7.hot cherry smoothies:= ");scanf("%d",glass);
	printf("8.hot coconut smoothies:= ");scanf("%d",glass);
	printf("9.hot durian smoothies:= ");scanf("%d",glass);
	printf("10.hot grape smoothies:= ");scanf("%d",glass);
	printf("11.hot mangosteen smoothies:= ");scanf("%d",glass);
	printf("12.hot pear smoothies:= ");scanf("%d",glass);
	printf("13.hot pineapple smoothies:= ");scanf("%d",glass);
	printf("14.hot pomegranate smoothies:= ");scanf("%d",glass);
	printf("15.hot watermelon smoothies:= ");scanf("%d",glass);
	printf("16.hot guava smoothies:= ");scanf("%d",glass);
	printf("smoothies     := ");scanf("%d",&glass);
	printf("total         := %d\n",total=glass*15);                                      (ตรงนี้อ่ะคับผมอยากให้ %d ทุกอันที่กดมา อย่างเช่น
	break;                                                                                   %dหัวข้อ 1ถึง 16 รับค่า อย่างละ 1  ก็ให้มารวมค่า  
                                                                                             ตรง smoothies อ่ะ รวม กัน ทุกอันเหมือนกับ%d+%d ทุกอันก็เป็น 16
case 2:                                                                                  ช่วยที่ถ้าไม่ได้ ก็ ไม่เป็นไรจร้า
	printf("< < : : hot fruit smoothies : : > >\n");
	printf("1.cool strawberry smoothies:= ");scanf("%d",glass);
	printf("2.cool orange smoothies:= ");scanf("%d",glass);
	printf("3.cool papaya smoothies:= ");scanf("%d",glass);
	printf("4.cool banana smoothies:= ");scanf("%d",glass);
	printf("5.cool apple smoothies:= ");scanf("%d",glass);
	printf("6.cool mango smoothies:= ");scanf("%d",glass);
	printf("7.cool cherry smoothies:= ");scanf("%d",glass);
	printf("8.cool coconut smoothies:= ");scanf("%d",glass);
	printf("9.cool durian smoothies:= ");scanf("%d",glass);
	printf("10.cool grape smoothies:= ");scanf("%d",glass);
	printf("11.cool mangosteen smoothies:= ");scanf("%d",glass);
	printf("12.cool pear smoothies:= ");scanf("%d",glass);
	printf("13.cool pineapple smoothies:= ");scanf("%d",glass);
	printf("14.cool pomegranate smoothies:= ");scanf("%d",glass);
	printf("15.cool watermelon smoothies:= ");scanf("%d",glass);
	printf("16.cool guava smoothies:= ");scanf("%d",glass);
	printf("smoothies:= %d",glass);
	printf("total = %d\n",glass*15);
	break;
case 3:
	printf("< < : = hot and cool fruit smoothies mix alcohol = : > >\n");
	printf("1.cool strawberry smoothies mix alcohol:= ");scanf("%d",glass);
	printf("2.cool orange smoothies mix alcohol:= ");scanf("%d",glass);
	printf("3.cool papaya smoothies mix alcohol:= ");scanf("%d",glass);
	printf("4.cool banana smoothies mix alcohol:= ");scanf("%d",glass);
	printf("5.cool apple smoothies mix alcohol:= ");scanf("%d",glass);
	printf("6.cool mango smoothies mix alcohol:= ");scanf("%d",glass);
	printf("7.cool cherry smoothies mix alcohol:= ");scanf("%d",glass);
	printf("8.cool coconut smoothies mix alcohol:= ");scanf("%d",glass);
	printf("9.cool durian smoothies mix alcohol:= ");scanf("%d",glass);
	printf("10.cool grape smoothies mix alcohol:= ");scanf("%d",glass);
	printf("11.cool mangosteen smoothies mix alcohol:= ");scanf("%d",glass);
	printf("12.cool pear smoothies mix alcohol:= ");scanf("%d",glass);
	printf("13.cool pineapple smoothies mix alcohol:= ");scanf("%d",glass);
	printf("14.cool pomegranate smoothies mix alcohol:= ");scanf("%d",glass);
	printf("15.cool watermelon smoothies mix alcohol:= ");scanf("%d",glass);
	printf("16.cool guava smoothies mix alcohol:= ");scanf("%d",glass);
	printf("17.hot strawberry smoothies mix alcohol:= ");scanf("%d",glass);
	printf("18.hot orange smoothies mix alcohol:= ");scanf("%d",glass);
	printf("19.hot papaya smoothies mix alcohol:= ");scanf("%d",glass);
	printf("20.hot banana smoothies mix alcohol:= ");scanf("%d",glass);
	printf("21.hot apple smoothies mix alcohol:= ");scanf("%d",glass);
	printf("22.hot mango smoothies mix alcohol:= ");scanf("%d",glass);
	printf("23.hot cherry smoothies mix alcohol:= ");scanf("%d",glass);
	printf("24.hot coconut smoothies mix alcohol:= ");scanf("%d",glass);
	printf("25.hot durian smoothies mix alcohol:= ");scanf("%d",glass);
	printf("26.hot grape smoothies mix alcohol:= ");scanf("%d",glass);
	printf("27.hot mangosteen smoothies mix alcohol:= ");scanf("%d",glass);
	printf("28.hot pear smoothies mix alcohol:= ");scanf("%d",glass);
	printf("29.hot pineapple smoothies mix alcohol:= ");scanf("%d",glass);
	printf("30.hot pomegranate smoothies mix alcohol:= ");scanf("%d",glass);
	printf("31.hot watermelon smoothies mix alcohol:= ");scanf("%d",glass);
	printf("32.hot guava smoothies mix alcohol:= ");scanf("%d",glass);
	printf("smoothies:= ");scanf("%d",&glass);
	printf("total = %d\n",glass*20);
	break;
case 4:
	printf("you want to Exit Program\n");
	break;
default:
	printf("you Select Choice is wrong\n");
	break;
}
	printf("receive       := ");scanf("%d",&receive);               ตรงนี้เป็นเงินที่รับเข้า พอรันเเล้ว มันจะ คำนวณได้แค่ 100 บาท
	printf("change        := %d\n",change=receive-total);      ถ้ามากกว่านั้น มัน มั่วๆๆมากๆๆลองค๊อป ไปแก้ไขให้ผมทีผมงงมาก

}
getch();
}




ขอบคุณนะคับ พอทำเส็จแล้ว ก็ เอา ที่ถูกต้องมาให้ผมด้วยนะคับ


ขอบคุณมากกกกกคราฟฟฟฟ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-08-13 20:09:42 By : bookhunter
 


 

No. 3



โพสกระทู้ ( 9 )
บทความ ( 0 )



สถานะออฟไลน์


บรรทัด 028 ตรงเดี่ยวเลยเปลี่ยนเป็น int choice,smoothies,glass,receive;

เนื่องจากท่านประกาศตัวแปรเป็น char มันรองรับ%c ไม่รองรับ %d ครับ...
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-10-11 13:45:12 By : dreamz
 


 

No. 4

Guest



แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-01-24 00:17:16 By : xay
 


 

No. 5

Guest


เขียน Code ไม่ค่อยเป็นระเบียบเลย ถ้าจัดให้ดูดีกว่านี้ก็จะ ok ดูง่าย+แก้ไขได้ง่ายนะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-05-16 15:07:13 By : คนมั่วๆ
 


 

No. 6

Guest


*****************************
M A I N M E N U
****************************
1. Selection
2. Looping
3. EXIT
*****************************
Input your Choice [1-3]…………….

กรณีที่ผู้ใช้กดเลือกหมายเลข 1
ให้รับข้อมูล รหัสนักนักศึกษา จำนวนหน่วยกิต เพื่อคำนวณหาราคาค่าลงทะเบียนประจำภาคการศึกษา โดยทางมหาวิทยาลัยคิดค่าหน่วยกิตๆ ละ 850 บาท นอกจากนี้ทางมหาวิทยาลัยให้มีการคิดค่าบำรุงการศึกษาภาคการศึกษาละ 3500 และค่าบำรุงสารสนเทศอีก 1500 บาท โดยทางมหาวิทยาลัยต้องการตรวจสอบก่อนการคำนวณค่าเทอมว่า หากนักศึกษาคนใดลงทะเบียนเกิน 21 หน่วยกิต ทางมหาวิทยาลัยจะต้องการให้แสดงข้อความว่า “No” และหยุดการทำงาน แต่หากคนใดลงทะเบียนไม่เกิน 21 หน่วยกิต ระบบจะรับลงทะเบียนตามเงื่อนไขที่กำหนดไว้ด้านบน
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-08-22 18:51:23 By : ช่วยหน่อยค่ะ
 


 

No. 7

Guest


Assignment:
นักวิจัยต้องการที่จะตรวจสอบการกดแป้นพิมพ์ของผู้ใช้โดยสนใจเฉพาะอักขระ A , E , I ,O และ U ว่าในการกดแป้นพิมพ์ทั้งหมด 25 ครั้งจะพบอักขระดังกล่าวตัวละกี่ครั้งโดยให้แสดงผลดังนี้ ( ให้ใช้ switch และ if-statement )
A = <เครื่องคำนวณจำนวนครั้งที่ถูกกด>
E = ………………….
I = …………………..
O = …………………..
U = …………………..


ช่วยด้วยครับผม ม. 5เองครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-12-05 19:57:46 By : winai
 


 

No. 8

Guest


Code (C#)
#include <iostream>

static const char *str[]={"f","h","t","M","f",NULL};

int main()
{
int Check;
	do
	{
		std::cout<<"\n1. f\n";
		std::cout<<"2. h\n";
		std::cout<<"3. t\n";
		std::cout<<"4. M\n";
		std::cout<<"5. f\n";
		std::cout<<"9. Exit\n";
		std::cout<<"Input Key : ";

		std::cin>>Check;
		
		if(Check >=1 && Check<=5)
			std::cout << "You live in " << str[Check-1] <<std::endl;

	}while(Check !=9);
	
	return 0;
}


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-12-13 00:26:07 By : Watt Duean
 


   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ช่วยคิดโค้ด ภาษา C ใน turbo c++ หน่อยค่า ว่าจะใช้ swicth case รวมกับ loop ตัวไหนดี
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 00
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่