Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2014
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. /*Scrivere un metodo che prenda in input una matrice bidimensionale frastagliata
  2. S di stringhe e restituisca la parola più lunga presente nella colonna completa
  3. più a destra di S (si suppone che ogni riga di S sia non vuota)*/
  4. # include <iostream>
  5. # include <string>
  6. using namespace std;
  7. string metodo (string ** S, int righe, int* colonne)
  8. {
  9.     string Max="";
  10.     int cMax=0;
  11.     for (int j=0; j<colonne; j++)
  12.     {
  13.         for (int i=0; i<righe; i++)
  14.         {
  15.             if (S[i][j]==0)
  16.             {
  17.                 cMax=j-1;
  18.             }
  19.         }
  20.     }
  21.     for (int i=0; i<righe; i++)
  22.     {
  23.         for (int j=cMax; j<colonne; j++)
  24.         {
  25.             if (Max<S[i][j])
  26.             {
  27.                 Max=S[i][j];
  28.             }
  29.         }
  30.     }
  31.     return Max;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement