Results 1 to 5 of 5

Thread: getline

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    AMD fan EvilDevil_'s Avatar
    Join Date: Dec:2010
    Location:
    Posts: 1,275

    getline

    .
    , , . , , getline .
    Code:
    #include<iostream>
    #include<string.h>
    using namespace std;
    struct employee
    {
         int Number, Ots, Pts, Age,;
         string Name;
         float Salary;       
    };
    void Input (struct employee emp[], int n)
    {
         int i;
         for(i=0;i<n;i++)
         {
              cin>>emp[i].Number;
              getline(cin,emp[i].Name);
              cin>>emp[i].Ots;
              cin>>emp[i].Pts;
              cin>>emp[i].Age;
              cin>>emp[i].Salary;
         }
    }
    void AgeSalary (struct employee emp[], int n, int min)
    {
         int i;
         cin>>min;
         for(i=0;i<n;i++)
              if((emp[i].Age<60)&&(emp[i].Salary<min))
              {
                   cout<<emp[i].Number<<endl;
                   cout<<emp[i].Name<<endl;
                   cout<<emp[i].Ots<<endl;
                   cout<<emp[i].Pts<<endl;
                   cout<<emp[i].Age<<endl;
                   cout<<emp[i].Salary<<endl;
              }
    }
    float AveSalary (struct employee emp[], int n)
    {
         int i;
         float S;
         for(i=0;i<n;i++)
              S+=emp[i].Salary;
         return S/n;
    }
    void MinSalary (struct employee emp[], int n, int min)
    {
         int i;
         for(i=0;i<n;i++)
              if(emp[i].Salary<min)
                   emp[i].Salary*=2;
    }
    void Output (struct employee emp[], int n)
    {
         int i;
         for(i=0;i<n;i++)
         {
              cout<<emp[i].Number<<endl;
              cout<<emp[i].Name<<endl;
              cout<<emp[i].Ots<<endl;
              cout<<emp[i].Pts<<endl;
              cout<<emp[i].Age<<endl;
              cout<<emp[i].Salary<<endl;
         }
    }
    int main ()
    {
         int n, min;
         cin>>n;
         cin>>min;
         struct employee emp[n];
         Input (emp, n);
         AgeSalary (emp, n, min);
         cout<<AveSalary (emp, n)<<endl;
         MinSalary (emp, n, min);
         Output (emp, n);
         return 0;
         system ("pause");     
    }
    ?

    Laa shay'a waqi'un moutlaq bale kouloun moumkine.
    Nulla &#233; reale, tutto &#233; lecito.

  2. #2
    Registered User omg's Avatar
    Join Date: Sep:2005
    Location: Sofia
    Posts: 182
    return 0;
    system ("pause");

    ,
    system ("pause") return 0;

  3. #3
    AMD fan EvilDevil_'s Avatar
    Join Date: Dec:2010
    Location:
    Posts: 1,275
    , , . , getline . -, . .

    Laa shay'a waqi'un moutlaq bale kouloun moumkine.
    Nulla &#233; reale, tutto &#233; lecito.

  4. #4
    Jedem das Seine Glimmer's Avatar
    Join Date: Jun:2004
    Location:
    Posts: 1,136
    , cin /n , default delimiting character getline(). cin.ignore() .

    cin>>emp[i].Number;
    cin.ignore(1024, '\n');
    getline(cin,emp[i].Name);
    DX58SO | x5670@4.2 | Megahalems | 3x4 EBJ40EG8BFWB-JS-F@1400 MHz | MSI GTX 970 1488/8000 | THNSNH256GBST + 3 x WD1600HLHX RAID 0 | X-Fi Titanium | P1-1250-BEFX
    The big trouble with dumb bastards is that they are too dumb to believe there is such a thing as being smart. Kurt Vonnegut

  5. #5
    AMD fan EvilDevil_'s Avatar
    Join Date: Dec:2010
    Location:
    Posts: 1,275
    . .

    Laa shay'a waqi'un moutlaq bale kouloun moumkine.
    Nulla &#233; reale, tutto &#233; lecito.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |