Facebook
From Chunky Crocodile, 4 Years ago, written in C++.
This paste is a reply to c++ from Cygan - view diff
Embed
Download Paste or View Raw
Hits: 294
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct Elem{
  6.     string napis;
  7.     Elem*next;
  8. };
  9.  
  10. int funkcja(Elem*&glowa, int D)
  11. {
  12.     if(glowa==NULL){
  13.         return 0;
  14.     }
  15.     bool mniejsze=true;
  16.     Elem*tmppop=NULL;
  17.     Elem*tmp=glowa;
  18.     while(true){
  19.         if(tmp->napis.size()>=D){
  20.             mniejsze=false;
  21.             return 0;
  22.         }
  23.         if(tmp->next==NULL)
  24.             break;
  25.  
  26.         tmppop=tmp;
  27.         tmp=tmp->next;
  28.  
  29.     }
  30.         if(glowa->next==NULL){
  31.             delete glowa;
  32.             glowa=NULL;
  33.             return 1;
  34.         }else if(glowa->next->next==NULL){
  35.             delete glowa->next;
  36.             delete glowa;
  37.             glowa=NULL;
  38.             return 2;
  39.         }else{
  40.             delete tmp;
  41.             tmppop->next=NULL;
  42.             tmp=glowa;
  43.             glowa=glowa->next;
  44.             delete tmp;
  45.             return 2;
  46.         }
  47.  
  48.     return 0;
  49. }
  50.  
  51. int main()
  52. {
  53.     cout << "Hello World!" << endl;
  54.     return 0;
  55. }