Need help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bigmoviebuff@gmail.com

    Need help

    Hi guys does any of you guys have this c++ program .
    I need the program to input a string and accept a word number and
    print this pattern.


    Input) This is a message
    Input)4

    output) s
    ssa
    essag
    message
    essag
    ssa
    s

    and if it is a even word for example golden then the output is


    ld
    olde
    golden
    olde
    ld


    Please can any of you guys write this program for me .
  • Zeppe

    #2
    Re: Need help

    bigmoviebuff@gm ail.com wrote:
    Please can any of you guys write this program for me .
    no.

    Comment

    • Triple-DES

      #3
      Re: Need help

      On 21 Feb, 10:31, bigmovieb...@gm ail.com wrote:
      Hi guys does any of you guys have this c++ program .
      I need the program to input a string and accept a word number and
      print this pattern.
      >
      Input) This is a message
      Input)4
      >
      output)                          s
                                        ssa
                                       essag
                                     message
                                       essag
                                         ssa
                                           s
      >
      and if it is a even word for example golden then the output is
      >
                                         ld
                                       olde
                                     golden
                                       olde
                                         ld
      >
      Please can any of you guys write this program for me .
      Sure, here you go:

      #include <iostream>
      #include <string>
      #include <vector>
      #include <algorithm>
      using namespace std;
      ostream& o = cout;
      istream& i = cin;
      typedef string s;
      typedef vector<sv;
      typedef s::iterator si;
      typedef size_t t;
      #define b_ begin()
      #define e_ end()
      int main() {
      s s_; v v_; t n;
      getline(i,s_);
      i>>n;
      while(--n) s_ = s(find(s_.b_, s_.e_,' ')+1,s_.e_);
      s_ = s(s_.b_,find(s_ .b_,s_.e_,' '));
      t d = 0u;
      t ll = s_.size();
      for(t l = ((ll ^ 1u) & 1u) + 1; l <= ll;) {
      si b = s_.b_ + (ll - l) / 2;
      o<< s(b, b + l) << "\n";
      l += 2 - d;
      if(l >= ll) d = 4u;
      }}

      Comment

      • red floyd

        #4
        Re: Need help

        bigmoviebuff@gm ail.com wrote:
        Hi guys does any of you guys have this c++ program .
        I need the program to input a string and accept a word number and
        print this pattern.
        >
        [redacted]
        Hi bigmoviebuff, you can find your program here:


        Comment

        • jason.cipriani@gmail.com

          #5
          Re: Need help

          On Feb 21, 2:19 pm, "P. Lepin" <le...@ranselet t.netwrote:
          Sure, why not.
          I see; so that's the way you want to be. Fine.

          *cracks knuckles*

          #include <stdio.h>
          int main(int Z,char*_,int N){switch(Z){ca se 0:if(*_){putcha r(
          main(Z-1,"double f;switch{}0x53* DEBUG=1+9.%|!+./1256789:I_"
          "abcdefghklmn"" oprstuwy",*_)); return main(Z,1+_,N);} return 0;
          case -1:if(N==*_)retu rn 36[_+Z] ;else return main(Z,_-Z,N);
          }return main(Z-Z,"cd0D5{.5xd=G dU>dD=U5|=+Ed{. dD..1tll*+=%19b "
          "*==*B5b0=Ul*+= %1l0=U1bB{G*b0u ul}+=|95h3+Ul.D +5{xl3xw;seif{w "
          "3;f3 edo",N);}

          That's C, mind you.

          Jason

          Comment

          • InsainFreak101@gmail.com

            #6
            Re: Need help

            If your newer to c++, I would start with the word, then delete the the
            end letters and display them above and below the original word until
            the length of the string is 1 or 2.

            Comment

            • Pavel Lepin

              #7
              Re: Need help


              jason.cipriani@ gmail.com <jason.cipriani @gmail.comwrote in
              <f71743fe-a37f-4cf1-96ba-045442e9c407@u6 9g2000hse.googl egroups.com>:
              On Feb 21, 2:19 pm, "P. Lepin" <le...@ranselet t.net>
              wrote:
              >Sure, why not.
              >
              I see; so that's the way you want to be. Fine.
              >
              *cracks knuckles*
              >
              #include <stdio.h>
              int main(int Z,char*_,int N){switch(Z){ca se
              0:if(*_){putcha r( main(Z-1,"double
              f;switch{}0x53* DEBUG=1+9.%|!+./1256789:I_"
              "abcdefghklmn"" oprstuwy",*_)); return main(Z,1+_,N);} return
              0;
              case -1:if(N==*_)retu rn 36[_+Z] ;else return
              main(Z,_-Z,N); }return
              main(Z-Z,"cd0D5{.5xd=G dU>dD=U5|=+Ed{. dD..1tll*+=%19b "
              "*==*B5b0=Ul*+= %1l0=U1bB{G*b0u ul}+=|95h3+Ul.D +
              {xl3xw;seif{w"
              "3;f3 edo",N);}
              >
              That's C, mind you.
              Since we started switching languages, I could've whipped out
              my Perl, and wouldn't THAT be horrible. But I won't. It's
              off-topic here. :-)

              (Translation: I'm chickening out!)

              --
              When all you have is a transformation engine, everything
              looks like a tree.

              Comment

              • James Kanze

                #8
                Re: Need help

                On Feb 21, 3:20 pm, Triple-DES <fire13...@hotm ail.comwrote:
                On 21 Feb, 10:31, bigmovieb...@gm ail.com wrote:
                [Obvious homework problem deleted...]
                Sure, here you go:
                #include <iostream>
                #include <string>
                #include <vector>
                #include <algorithm>
                using namespace std;
                ostream& o = cout;
                istream& i = cin;
                typedef string s;
                typedef vector<sv;
                typedef s::iterator si;
                typedef size_t t;
                #define b_ begin()
                #define e_ end()
                int main() {
                s s_; v v_; t n;
                getline(i,s_);
                i>>n;
                while(--n) s_ = s(find(s_.b_, s_.e_,' ')+1,s_.e_);
                s_ = s(s_.b_,find(s_ .b_,s_.e_,' '));
                t d = 0u;
                t ll = s_.size();
                for(t l = ((ll ^ 1u) & 1u) + 1; l <= ll;) {
                si b = s_.b_ + (ll - l) / 2;
                o<< s(b, b + l) << "\n";
                l += 2 - d;
                if(l >= ll) d = 4u;
                }}
                Beautiful. It really pleases me to see that someone here has
                finally learned how to respond to homework requests with some
                originality.

                --
                James Kanze (GABI Software) email:james.kan ze@gmail.com
                Conseils en informatique orientée objet/
                Beratung in objektorientier ter Datenverarbeitu ng
                9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

                Comment

                Working...