เรื่องอาร์เรย์ในภาษาซีอะค่ะ ใครมีความรู้ช่วยหน่อย | เว็บบอร์ด วิชาการ.คอม

เรื่องอาร์เรย์ในภาษาซีอะค่ะ ใครมีความรู้ช่วยหน่อย

โพสต์เมื่อ: 17:07 วันที่ 12 ก.ค. 2555         ชมแล้ว: 14,164 ตอบแล้ว: 2
วิชาการ >> กระทู้ >> เทคโนโลยี >> เทคโนโลยีสารสนเทศ
คืองี้นะคะ เขียนโปรแกรมอ่ะค่ะ โจทย์ว่า ให้รับค่าเข้ามาสิบค่า เอามาเก็บไว้ แล้วรับเข้ามาอีกค่านึง ให้หาว่าค่าที่รับเข้ามาใหม่ตรงกับค่าใดค่าหนึ่งที่รับเข้ามาก่อนหน้านี้รึเปล่า ถ้ามีให้แสดงที่อยู่และค่านั้นๆ อ่ะค่ะ ช่วยทีนะคะ จนปัญญา


D to the E and W(202.29.53.1)





จำนวน 2 ความเห็น, หน้าที่ | -1-
ความเห็นเพิ่มเติมที่ 1 12 ก.ค. 2555 (23:35)

#include <stdio.h>
#include <conio.h>
int main()
{
    int score[10];
    int n,i;
    printf("Enter number 1: ");
    scanf("%d",&score[0]);
    printf("Enter number 2: ");
    scanf("%d",&score[1]);
    printf("Enter number 3: ");
    scanf("%d",&score[2]);
    printf("Enter number 4: ");
    scanf("%d",&score[3]);
    printf("Enter number 5: ");
    scanf("%d",&score[4]);
    printf("Enter number 6: ");
    scanf("%d",&score[5]);
    printf("Enter number 7: ");
    scanf("%d",&score[6]);
    printf("Enter number 8: ");
    scanf("%d",&score[7]);
    printf("Enter number 9: ");
    scanf("%d",&score[8]);
    printf("Enter number 10: ");
    scanf("%d",&score[9]);
   
    printf("Enter number: ");
    scanf("%d",&n);


    if(score[0]==n)
{
    printf("%d",score[0]);
}
    else if(score[1]==n)
{
    printf("%d",score[1]);
}
    else if(score[2]==n)
{
    printf("%d",score[2]);
}
    else if(score[3]==n)
{
    printf("%d",score[3]);
}
    else if(score[4]==n)
{
    printf("%d",score[4]);
}
    else if(score[5]==n)
{
    printf("%d",score[5]);
}
    else if(score[6]==n)
{
    printf("%d",score[6]);
}
    else if(score[7]==n)
{
    printf("%d",score[7]);
}
    else if(score[8]==n)
{
    printf("%d",score[8]);
}
    else if(score[9]==n)
{
    printf("%d",score[9]);
}  
getch();
}


นกแสก
ร่วมแบ่งปัน4186 ครั้ง - ดาว 251 ดวง

ความเห็นเพิ่มเติมที่ 2 18 ก.ค. 2555 (11:12)
แนะนำใช้เป็น for วนดีกว่าครับ


for(int i=0;i<10;i++){
printf("Enter number %d: ",(i+1));
scanf("%d",&score[i]);
}
//Enter value to check

for(int i=0;i<10;i++){
if(score[i]==value){
//Process
}else{
//Process

	}

}

iclanzer
ร่วมแบ่งปัน39 ครั้ง - ดาว 56 ดวง

จำไว้ตลอด

ความเห็นเพิ่มเติม วิชาการ.คอม
ชื่อ / email:
ข้อความ

กรุณาล๊อกอินก่อน เพื่อโพสต์รูปภาพ และ ใช้ LaTex ค่ะ สมัครสมาชิกฟรีตลอดชีพที่นี่
กรอกตัวอักษรตามภาพ
ตัวช่วย 1: CafeCode วิธีการใช้
ตัวช่วย 2: VSmilies วิธีการใช้
ตัวช่วย 3: พจนานุกรมไทย ออนไลน์ ฉบับราชบัณฑิต
ตัวช่วย 4 : dictionary ไทย<=>อังกฤษ ออนไลน์ จาก NECTEC
ตัวช่วย 5 : ดาวน์โหลด โปรแกรมช่วยพิมพ์ Latex เพื่อแสดงสมการบนวิชาการ.คอม
Google  
ผู้สนับสนุน คลิีกดูสถิติ
อีเมล : star@vcharkarn.com
โทรศัพท์ : 02-9620127
Creative Commons License สงวนสิทธิ์บางประการภายใต้สัญญาอนุญาต ครีเอทีฟคอมมอนส์ แสดงที่มา-ไม่ใช้เพื่อการค้า-ไม่ดัดแปลง 3.0 ประเทศไทย.
ท่านสามารถนำเนื้อหาในส่วนบทความไปใช้ แสดง เผยแพร่ โดยต้องอ้างอิงที่มา ห้ามใช้เพื่อการค้าและห้ามดัดแปลง
Page generated in0.0233 seconds !