159 - Word Crosses

All about problems in Volume 1. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

NAbdulla
New poster
Posts: 31
Joined: Wed Jul 30, 2014 3:40 pm
Contact:

159 - Word Crosses PresentationE

Post by NAbdulla »

Help please.......

Code: Select all

#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int main()
{
    //freopen("out.txt", "w", stdout);
    char p11[15], p12[15], p21[15], p22[15];
    int p11l, p12l, p21l, p22l, v1, v2, p11c, p12c, p21c, p22c;
    int i, j, k, m, n, w;
    bool c1, c2, f = false;
    while(scanf("%s", p11) == 1){
        if(p11[0] == '#' && p11[1] == '\0')break;
        scanf("%s %s %s", p12, p21, p22);
        p11l = strlen(p11);
        p12l = strlen(p12);
        p21l = strlen(p21);
        p22l = strlen(p22);
        c1 = false;
        c2 = false;

        for(i = 0; i < p11l; i++){
            for(j = 0; j < p12l; j++){
                if(p11[i] == p12[j]){
                    c1 = true;
                    p11c = i+1;
                    p12c = j+1;
                    break;
                }
            }
            if(c1)break;
        }
        for(i = 0; i < p21l; i++){
            for(j = 0; j < p22l; j++){
                if(p21[i] == p22[j]){
                    c2 = true;
                    p21c = i+1;
                    p22c = j+1;
                    break;
                }
            }
            if(c2)break;
        }

        if(f)putchar('\n');
        f = true;

        if(c1 && c2){
            if(p12c >= p22c){
                m = 0;
                n = 0;
                v1 = p12c - p22c;
                for(i = 0; i < v1; i++){
                    for(j = 1; j < p11c; j++)putchar(' ');
                    printf("%c\n", p12[m++]);
                }

                w = (p11l - p11c) + 3 + (p21c - 1);

                for(; i < p12l; i++){
                    if(i == p12c-1){
                        printf("%s   %s", p11, p21);
                        m++;
                        n++;
                    }
                    else{
                        for(j = 1; j < p11c; j++)putchar(' ');

                        printf("%c", p12[m++]);

                        for(j = 0; j < w; j++)putchar(' ');

                        if(n < p22l)printf("%c", p22[n++]);
                        else putchar(' ');
                    }
                    printf("\n");
                }
                if(p22l+v1 > p12l){
                    v2 = p22l + v1 - p12l;
                    w = p11l + 3 + (p21c-1);
                    for(i = 0; i < v2; i++){
                        for(j = 0; j < w; j++)putchar(' ');

                        printf("%c\n", p22[n++]);
                    }
                }
            }
            else{
                m = 0;
                n = 0;
                v1 = p22c - p12c;
                w = p11l + 3 + (p21c-1);
                for(i = 0; i < v1; i++){
                    for(j = 0; j < w; j++)putchar(' ');

                    printf("%c\n", p22[n++]);
                }

                w = (p11l - p11c) + 3 + (p21c - 1);

                for(; i < p22l; i++){
                    if(i == p22c-1){
                        printf("%s   %s", p11, p21);
                        m++;
                        n++;
                    }
                    else{
                        for(j = 1; j < p11c; j++)putchar(' ');

                        if(m < p12l)printf("%c", p12[m++]);
                        else putchar(' ');

                        for(j = 0; j < w; j++)putchar(' ');

                        printf("%c", p22[n++]);
                    }
                    printf("\n");
                }
                if(v1+p12l > p22l){
                    v2 = v1 + p12l - p22l;
                    for(i = 0; i < v2; i++){
                        for(j = 1; j < p11c; j++)putchar(' ');
                        putchar(p12[m++]);
                        printf("\n");
                    }
                }
            }
        }
        else printf("Unable to make two crosses\n");
    }
    return 0;
}
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 159 - Word Crosses

Post by brianfry713 »

Next time post in the existing thread.
Don't print spaces at the end of a line.

Input:

Code: Select all

K TWALZT LJWON AGZMFB
TQFEOCULHE C SNCN PZXF
MFUMRCP VIHBWKVHT Z DTKHJM
ILB YITMBVDFS OVJYRQTT QYNBHW
FGCICCQVOT SYMFMKPNB IWBZWQ DMT
SVQWAIU BOIZBQNLF OOJ PKK
OPTHZNERME GVCUFD VQ CRA
AO M QAN JOBPFN
ETRIPWLNU ZWT P OAJPQJED
TEHYT FMWNEVZT BSNW D
LDCA NGYFZFOAYU NQ RLVKCYC
WZT KYRKTGST UY UZY
MQZFEXPG TWSSRJCRDO JHGXDGBXF CRPB
TYNCWJA BUZGLEWYO ENIK HQNJJELIA
XCHG XKYZSKD KRWOE AUMSHXE
KMO LSF YDGXC JFO
ZKJFRJAFEJ IXNWNLH QBGTHF HOFW
GIULZD EJXJ WYNMJV ZYBVII
PYZNH YBTX GEQF ICNXOWUL
TPUDXPSWOI WGHRFQXL DAQHPQXLK LFX
IVUDTLLYJT AYXXME OWJEMIPZR EOINLCQ
PDDYWKYWI K CZMODBW ANX
E TPJJWB BZMNAJX TLEUA
XBRSBGRHK BCHMAIBBK OMYMMUZSOZ MAEGDKXL
VM EYZPBCBPQN EBJG YFGKIMSNXP
UMMVSNUHQ I OXVVAGBUEI QSP
GOZ ILV EIZNYX GNV
IWJLSQUWGM PSBQZLEWQI RXEOVMETR RDY
TU ZGTQBWJC NYYXEQU GSX
L ZCR NMTUOBPECM GUCEUZIM
TVMSHZG B F OAICCYJ
MYN BTCACRWXM P JXCKXJAM
LOQLZ XYLFZFJBJ YGQ VMS
OESXFGLQW BWYYULFVQO BTWHJ EVZZJDRJKZ
A WD WDNJKKCB DUFLDMRZLQ
R TB QEEOH MNNVXX
YGBSMOWY XMWHDF GOTKSHURVH QGEOFMR
YFVZKUNICQ F E JYHDP
MWSSCIXOZ PGUOTPBB TRYRXWAVFF JRLDKPMH
NGSUDIPU QN KLYJJ F
GUX HAHWORZE UYCEPWQH WRUW
FXKTDESANV JJB PAEPF ED
MNZFJWIP SK YFWLA ULJHBMNQR
VUZJJ OT ZKQR MQZ
DBTAN HQOUG VDCUML DGSCQKTN
LOHRQ RFEYVVU CPJEMVSJAY CPM
E LSUCIW NCTKXOOA ZG
WYBXXF OTZUEN A XWLMBE
YSNAYMHPIH H XJWRIQV DWNCUYOV
NUXAWVODM NFGTCP T IRXLNMP
KEFPRB UZJIFVJSC LFHDAJMRJ GVPQGTXVMA
GZSRENAY S XCPZL RU
ZQ RWPQT QCIS B
JBX WJAYAA ETGJ WDMUSCP
TRFN GLWKKAGT EWCPAVV QTOCNG
CBZVH IPC ZMFHIHLE DGF
PXSFZHL KOHHX Q YVOKCWSLJY
MEDNVAHACO IACPIBLY LVHWZ QKOR
DVLSR BT PH SLPCMC
F ZOM T K
TSORFGKT DIBMITXZ MB RP
FBYAGKJ FYSKGCFQIQ UY SXJGA
ZQIETGG SPDXPXIWCP KFFEDTYCC DKDVUJQ
PSSHX WUAUWRIIX NCINFKUK Z
QJZSAT HQ GNFALYJUVA YJWF
SP SYIDX DRONHT WAVIYG
UHLUS ZLCQFUOO NRCEHROAMK KUC
WWB STTRHXJM ZCSN UTAO
CCWGMQJHNF YACTTJQ XJEA RVYNWMWA
SHDJQ YXSWX SRHIWFS HVU
THYHFBWYI JANJ HHXEZONIMS O
XICR CYXFWX ZI MRNUYKAY
NGM KAHHLLACQ BV ALZIANBN
AZHAZXGN SOMZBA DSDHPCJAD DRVQYXSIX
FFFKXVYZWA BS KKGUK Q
BLGBLYLIRQ WCN DM FNRA
BK XWKNKNZ Q S
UJUKGZYZC PJAIJRJVR SDUESVWJ QLCZ
OF MHIZYUZGD P MYTR
XKQVTYLE MLQSQFBAE UFFAZWBL WDQT
GQIGDM PZBJRGK KLORQOQ REKNJAIWIA
PDUZVTA L RFSETJXKC BGWRPYZ
IATX NXAIXHTGYA EUIBG NJS
AH AWSARR GQIO PKUPKUTGC
MOIW UYPFY ZA RIK
QZ FJ UVONCSKQ TOPPNHWNWW
BPWNW MWTXPNV CZ PPHKG
Z HVGETWHI UFGHDZG O
AT Y SHSYFTTPO TIAASUWXBF
CMXTPXM XUM O L
HAXKVHKX FUZIZ M ZFFY
ZVNLBDZO GRKQMRBMR GRQHVCXUK UDDRROU
PIHVZ NOKQAEYI QR V
OFSIIVZBL YADHXDALTM VQCFNUWF NVYF
JBEK XKNBTKGVX IB AFDQBZX
MTTU CVB JABYDVLJSI CLK
QNVU SPBLIVKLSN CPDAT LETWRVHBA
PVUEOJF TDNEVCGZSK LKN DJIB
KBTB PFNA QTPGANIGM SOP
EHKNPN ZPB O HDSUVMLBO
#
AC output:

Code: Select all

Unable to make two crosses

Unable to make two crosses

Unable to make two crosses

Y        Q
ILB   OVJYRQTT
T        N
M        B
B        H
V        W
D
F
S

Unable to make two crosses

Unable to make two crosses

Unable to make two crosses

Unable to make two crosses

            O
 Z          A
 W          J
ETRIPWLNU   P
            Q
            J
            E
            D

Unable to make two crosses

Unable to make two crosses

  K
  Y
  R
  K
WZT   UY
  G   Z
  S   Y
  T

Unable to make two crosses

 B
 U
 Z        H
 G        Q
 L        N
 E        J
 W        J
TYNCWJA   ENIK
 O        L
          I
          A

           A
           U
           M
           S
           H
           X
XCHG   KRWOE
K
Y
Z
S
K
D

Unable to make two crosses

Unable to make two crosses

Unable to make two crosses

Unable to make two crosses

    W
    G
    H
    R
    F              L
    Q              F
TPUDXPSWOI   DAQHPQXLK
    L

       A     E
IVUDTLLYJT   OWJEMIPZR
       X     I
       X     N
       M     L
       E     C
             Q

Unable to make two crosses

Unable to make two crosses

XBRSBGRHK   OMYMMUZSOZ
 C           A
 H           E
 M           G
 A           D
 I           K
 B           X
 B           L
 K

Unable to make two crosses

Unable to make two crosses

Unable to make two crosses

P
S
B
Q
Z
L
E
W
Q
IWJLSQUWGM   RXEOVMETR
             D
             Y

Z       G
G       S
TU   NYYXEQU
Q
B
W
J
C

Unable to make two crosses

Unable to make two crosses

Unable to make two crosses

Unable to make two crosses

B
W
Y
Y
U
L               E
F               V
V               Z
Q               Z
OESXFGLQW   BTWHJ
                D
                R
                J
                K
                Z

Unable to make two crosses

Unable to make two crosses

    X      Q
YGBSMOWY   GOTKSHURVH
    W      E
    H      O
    D      F
    F      M
           R

Unable to make two crosses

       P
       G
       U     J
MWSSCIXOZ   TRYRXWAVFF
       T     L
       P     D
       B     K
       B     P
             M
             H

Unable to make two crosses

Unable to make two crosses

Unable to make two crosses

Unable to make two crosses

Unable to make two crosses

Unable to make two crosses

LOHRQ   CPJEMVSJAY
   F    P
   E    M
   Y
   V
   V
   U

Unable to make two crosses

Unable to make two crosses

               D
YSNAYMHPIH   XJWRIQV
               N
               C
               U
               Y
               O
               V

Unable to make two crosses

             G
             V
             P
             Q
             G
  U          T
  Z          X
  J          V
  I          M
KEFPRB   LFHDAJMRJ
  V
  J
  S
  C

Unable to make two crosses

Unable to make two crosses

Unable to make two crosses

G
L
W
K
K        Q
A        T
G        O
TRFN   EWCPAVV
         N
         G

I         D
P         G
CBZVH   ZMFHIHLE

Unable to make two crosses

Unable to make two crosses

Unable to make two crosses

Unable to make two crosses

Unable to make two crosses

Unable to make two crosses

  S
  P
  D
  X
  P
  X       D
ZQIETGG   KFFEDTYCC
  W       D
  C       V
  P       U
          J
          Q

Unable to make two crosses

           Y
           J
H          W
QJZSAT   GNFALYJUVA

Unable to make two crosses

Z
L
C
Q         K
F         U
UHLUS   NRCEHROAMK
O
O

Unable to make two crosses

                R
                V
                Y
                N
                W
Y               M
A               W
CCWGMQJHNF   XJEA
T
T
J
Q

Y
X
SHDJQ   SRHIWFS
W         V
X         U

Unable to make two crosses

Unable to make two crosses

Unable to make two crosses

S
O
M
Z
B
AZHAZXGN   DSDHPCJAD
           R
           V
           Q
           Y
           X
           S
           I
           X

Unable to make two crosses

Unable to make two crosses

Unable to make two crosses

Unable to make two crosses

Unable to make two crosses

  M
  L
XKQVTYLE   UFFAZWBL
  S             D
  Q             Q
  F             T
  B
  A
  E

P
Z
B
J        R
R        E
GQIGDM   KLORQOQ
K        N
         J
         A
         I
         W
         I
         A

Unable to make two crosses

Unable to make two crosses

     P
     K
     U
     P
     K
     U
     T
AH   GQIO
W    C
S
A
R
R

Unable to make two crosses

Unable to make two crosses

Unable to make two crosses

Unable to make two crosses

Unable to make two crosses

Unable to make two crosses

Unable to make two crosses

    G
    R
    K
    Q       U
    M       D
    R       D
ZVNLBDZO   GRQHVCXUK
    M       R
    R       O
            U

Unable to make two crosses

        Y
        A
        D
        H
        X
        D
        A   N
OFSIIVZBL   VQCFNUWF
        T   Y
        M   F

        A
 X      F
 K      D
 N      Q
JBEK   IB
 T      Z
 K      X
 G
 V
 X

Unable to make two crosses

 S
 P        L
 B        E
 L        T
 I        W
 V        R
 K        V
 L        H
 S        B
QNVU   CPDAT

Unable to make two crosses

Unable to make two crosses

         H
         D
         S
         U
         V
         M
         L
    Z    B
EHKNPN   O
    B
Check input and AC output for thousands of problems on uDebug!
NAbdulla
New poster
Posts: 31
Joined: Wed Jul 30, 2014 3:40 pm
Contact:

Re: 159 - Word Crosses

Post by NAbdulla »

Thank you.
Post Reply

Return to “Volume 1 (100-199)”