Filter löschen
Filter löschen

How to connect two displays?

1 Ansicht (letzte 30 Tage)
Minhao Wang
Minhao Wang am 25 Sep. 2020
Kommentiert: Minhao Wang am 25 Sep. 2020
clc;clear
C1 = input('Please enter a code to break: ' , 's');
if length(C1) ~= 6
disp('Decoy message: Not a six-digit number.');
else
A = mod(sum(C1 - '0'),2);
end
if A == 1
disp('Decoy message: Sum is odd.')
else
C2 = (C1(1) - '0') * (C1(2) - '0') - (C1(3) - '0');
end
switch C2
case 1
disp('Rescue on Monday')
case 2
disp('Rescue on Tuesday')
case 3
disp('Rescue on Wednesday')
case 4
disp('Rescue on Thursday')
case 5
disp('Rescue on Friday')
case 6
disp('Rescue on Saturday')
case 7
disp('Rescue on Sunday')
otherwise
disp('Decoy message:Invalid rescue day.');
end
F1 = str2num(C1(4));
F2 = str2num(C1(5));
F3 = str2num(C1(6));
if mod(F1,3) == 0
B = F2 - F3;
else
B = F3 - F2;
end
switch(B)
case 1
disp('at the bridge.');
case 2
disp('at the library.');
case 3
disp('at the river crossing.');
case 4
disp('at the airport.');
case 5
disp('at the bus terminal.');
case 6
disp('at the hospital.');
case 7
disp('at the St. Petes Church.');
otherwise
disp('Decoy message:Invalid rendezvous point.');
end
If we run this Script and enter 510129,it will appear:
Please enter a code to break: 510129
Rescue on Friday
at the St. Petes Church.
But I would like to make it appear :
Please enter a code to break: 510129
Rescue on Friday at the St. Petes Church.
How do I do that?

Akzeptierte Antwort

KSSV
KSSV am 25 Sep. 2020
Bearbeitet: KSSV am 25 Sep. 2020
clc;clear
C1 = input('Please enter a code to break: ' , 's');
if length(C1) ~= 6
disp('Decoy message: Not a six-digit number.');
else
A = mod(sum(C1 - '0'),2);
end
if A == 1
disp('Decoy message: Sum is odd.')
else
C2 = (C1(1) - '0') * (C1(2) - '0') - (C1(3) - '0');
end
switch C2
case 1
str1 = 'Rescue on Monday' ;
case 2
str1 = 'Rescue on Tuesday' ;
case 3
str1 = 'Rescue on Wednesday' ;
case 4
str1 = 'Rescue on Thursday' ;
case 5
str1 = 'Rescue on Friday' ;
case 6
str1 = 'Rescue on Saturday' ;
case 7
str1 = 'Rescue on Sunday' ;
otherwise
str1 = 'Decoy message:Invalid rescue day.' ;
end
F1 = str2num(C1(4));
F2 = str2num(C1(5));
F3 = str2num(C1(6));
if mod(F1,3) == 0
B = F2 - F3;
else
B = F3 - F2;
end
switch(B)
case 1
str2 = ('at the bridge.');
case 2
str2 = ('at the library.');
case 3
str2 = ('at the river crossing.');
case 4
str2 = ('at the airport.');
case 5
str2 = ('at the bus terminal.');
case 6
str2 = ('at the hospital.');
case 7
str2 = ('at the St. Petes Church.');
otherwise
str2 = ('Decoy message:Invalid rendezvous point.');
end
str = [str1,' ', str2] ;
fprintf("%s\n",str) ;

Weitere Antworten (0)

Kategorien

Mehr zu Properties finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by