giúp em với, sử dụng repeat until để lưu từ vào mảng a
vd: Mai Thu
output:
a[1]=Mai
a[2]=Thu
giúp e
0 bình luận về “giúp em với, sử dụng repeat until để lưu từ vào mảng a vd: Mai Thu output: a[1]=Mai a[2]=Thu giúp e”
program gggg;
uses crt; var s:string; i,n:longint; a:array[1..100]of string; begin clrscr; write(‘nhap s: ‘); readln(s); s:=s+’ ‘; repeat inc(i); if(s[i]=’ ‘)and(s[i+1]<>’ ‘)then inc(n) else if s[i]<>’ ‘ then a[n]:=a[n]+s[i]; until i=length(s); for i:=1 to n do writeln(‘a[‘,i,’]=’,a[i]); readln; end.
uses crt; var s:string; i,n:longint; a:array[1..100000]of string; begin clrscr; write(‘s=’);readln(s); s:=’ ‘+s; repeat inc(i); if(s[i]=’ ‘)and(s[i+1]<>’ ‘)then inc(n) else if s[i]<>’ ‘ then a[n]:=a[n]+s[i]; until i=length(s); for i:=1 to n do writeln(‘a[‘,i,’]=’,a[i]); readln end.
program gggg;
uses crt;
var s:string; i,n:longint; a:array[1..100]of string;
begin
clrscr;
write(‘nhap s: ‘); readln(s);
s:=s+’ ‘;
repeat
inc(i);
if(s[i]=’ ‘)and(s[i+1]<>’ ‘)then inc(n) else if s[i]<>’ ‘ then a[n]:=a[n]+s[i];
until i=length(s);
for i:=1 to n do writeln(‘a[‘,i,’]=’,a[i]);
readln;
end.
uses crt;
var s:string; i,n:longint; a:array[1..100000]of string;
begin
clrscr;
write(‘s=’);readln(s);
s:=’ ‘+s;
repeat
inc(i);
if(s[i]=’ ‘)and(s[i+1]<>’ ‘)then inc(n) else if s[i]<>’ ‘ then a[n]:=a[n]+s[i];
until i=length(s);
for i:=1 to n do writeln(‘a[‘,i,’]=’,a[i]);
readln
end.