Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
486 views
in Technique[技术] by (71.8m points)

emu8086 - Input is to be taken from a-z or A-Z. We need to have the first and last Capital letters of that input string as the output

Input is to be taken from a-z or A-Z and the input ends when we give a star(*). We need to have the first and last Capital letters of that input characters as the output. also, we should show the input we have taken each time. N.B. We take the inuputs character by character, not as a string.

Test case 1: input: aAbCcP* output: AP

Test case 2: input: ZabCBc* output: ZB

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
    $test1="aAbCcP*";
    $test="ZabCBc*";
    $i=0;
    $a=[];
    $final_string="";
    while(!empty($test[$i])){ 
        if(ctype_upper($test[$i])){
            $final_string=$test[$i];
            array_push($a,$final_string);
        }
        $i++;
  }
  $first = reset($a);
$last = end($a);

  echo  $first. $last;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...