السابق التالي
0 / 23
الوحدة النمطية DEMO-32-108DEMO-C-32

First Occurrence

DEMO-C-32 • Programming in C

Browser-only practice

بيان المشكلة

Write a program that finds the index of the first occurrence of a specific character in a string. Print -1 if the character is not found.

قيود

Max string length: 100

تنسيق الإدخال

Input:

C S

تنسيق الإخراج

Output:

Index

حالات اختبار نموذجية

Submit runs every public testcase in this browser. Results and code never leave this device.

العينة رقم 1
عينة ظاهرة
z uber
-1
Character z is found at index -1 in uber.
العينة رقم 2
عينة ظاهرة
t packet
5
Character t is found at index 5 in packet.
العينة رقم 3
عينة ظاهرة
t date
2
Character t is found at index 2 in date.
العينة رقم 4
عينة ظاهرة
i quince
2
Character i is found at index 2 in quince.

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
إعدادات المحرر