(ในกรณีนี้ผม เอา array มาบวกกันครับ)คือผมต้องการให้ sum มีค่า เท่ากับ ตัวเเปร x ครับควรปรับตรงไหนดีครับ....
#include <stdio.h>
int main()
{
int a[10] = {5, 10, 15, 20, 25, 30, 35, 40,45,50};
int b[10] = {10, 15, 20, 25, 30, 35, 40, 45,50,55};
int sum[10];
int x ; //input number of x
int i; //for loop
printf("input you number of x: ");
scanf("%d",&x);
printf("--------------------------");
for(i=0;i<10;i++){
printf("\nindex of arrayA[%d]= %d ",i+0, a);
printf("\nindex of arrayB[%d]= %d \n",i+0, b);
if(x == sum) {
printf("[ you have number in array = x ] <------------------<");
}else{
printf("\n[ you don't have number in array = x ]");
}
sum = a + b;
printf(" \nsum of: %d\n ",sum);
printf("\n============================================================");
}
return 0;
}
โจทย์ภาษา c++ ขอถามพี่ๆหน่อยครับ .
#include <stdio.h>
int main()
{
int a[10] = {5, 10, 15, 20, 25, 30, 35, 40,45,50};
int b[10] = {10, 15, 20, 25, 30, 35, 40, 45,50,55};
int sum[10];
int x ; //input number of x
int i; //for loop
printf("input you number of x: ");
scanf("%d",&x);
printf("--------------------------");
for(i=0;i<10;i++){
printf("\nindex of arrayA[%d]= %d ",i+0, a);
printf("\nindex of arrayB[%d]= %d \n",i+0, b);
if(x == sum) {
printf("[ you have number in array = x ] <------------------<");
}else{
printf("\n[ you don't have number in array = x ]");
}
sum = a + b;
printf(" \nsum of: %d\n ",sum);
printf("\n============================================================");
}
return 0;
}