#include
#define LENGTH ((size_t)10)
int main(void) {
int sequence[LENGTH];
size_t index, position = 0;
int key;
scanf("%d", &key);
for (index = 0; index < LENGTH; ++index) {
scanf("%d", &sequence[index]);
}
for (index = 0; index < LENGTH; ++index) {
++position;
if (sequence[index] == key) {
printf("index: %zu\nposition: %zu\n", index, position);
break;
}
}
if (!position) {
puts("-1");
}
return 0;
}
#include
#define LENGTH ((size_t)10)
int main(void) {
int sequence[LENGTH];
size_t index, position = 0, count = 0;
int key;
scanf("%d", &key);
for (index = 0; index < LENGTH; ++index) {
scanf("%d", &sequence[index]);
}
for (index = 0; index < LENGTH; ++index) {
++position;
if (sequence[index] == key) {
++count;
printf("%zu %zu\n", index, position);
}
}
if (!count) {
puts("-1");
}
return 0;
}
Вот так правильно! #include
#define LENGTH ((size_t)10)
int main(void) {
int sequence[LENGTH];
size_t index, count = 0;
int key;
scanf("%d", &key);
for (index = 0; index < LENGTH; ++index) {
scanf("%d", &sequence[index]);
}
for (index = 0; index < LENGTH; ++index) {
if (sequence[index] == key) {
++count;
printf("%zu %zu\n", index, index + 1);
}
}
if (!count) {
puts("-1");
}
return 0;
}
#include<stdio.h>
int main()
{
int a[10];
int f=0,key;
scanf("%d",&key);
for(int i=0;i<10;i++)
{
scanf("%d",&a[i]);
}
for(int i=0;i<10;i++)
{
f++;
if(a[i]==key)
{
printf("%d\n%d\n",i,f);
}
if(key!=a[i])
printf("-1\n");
}
}