#include <iostream>
#include <stdio.h>
#include <sstream>
using namespace std;
typedef struct note
{
    int xs,zs;
    struct note *next;
}note;
note* CreatList()
{
    note *head,*q,*p;
    head=(note*)malloc(sizeof(note));
    head->next=NULL;
    q=head;
    string b;
    getline(cin,b);
    stringstream ss(b);
    int aa,bb;
    while(ss>>aa>>bb)
    {
        p=(note*)malloc(sizeof(note));
        p->xs=aa;
        p->zs=bb;
        p->next=NULL;
        q->next=p;
        q=p;
    }
    return head;
}
note* QD(note* p)
{
    note *head;
    head=p;
    while(p!=NULL)
    {
        if(p->zs!=0)
        {
            p->xs=p->xs*p->zs;
            p->zs=p->zs-1;
        }
        else
        {
            p->xs=0;
            p->zs=0;
        }
        p=p->next;
    }
    return head;
}
void Print(note* p)
{
    int f=0;
    p=p->next;
    if(p->xs==0)
    cout<<"0 0"<<endl;
    else
    {
        while(p!=NULL)
        {
            if(!f)
            {
                cout<<p->xs<<" "<<p->zs;
                f=1;
            }
            else
            {
                if(p->xs!=0)
                cout<<" "<<p->xs<<" "<<p->zs;
            }
            p=p->next;
            
        }
        cout<<endl;
    }
}
int main()
{
    note *p=CreatList();
    note *p1=QD(p);
    Print(p1);
}

 

#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
    int a,b,f=0;
    while(scanf("%d %d",&a,&b))
    {
        if(b)
        {
            if(f)printf(" ");
            printf("%d %d",a*b,b-1);
            f=1;
        }
        if(getchar()!=' ')break;
    }
    if(!f)printf("0 0");
    cout<<endl;
}

 

#include <stdio.h>
#include <iostream>
#include <sstream>
using namespace std;

struct note
{
    int xs,zs;
}a[1000];
int main()
{
    string b;
    getline(cin,b);
    stringstream ss(b);
    int aa,bb,i=0;
    while(ss>>aa>>bb)
    {
        a[i].xs=aa;
        a[i].zs=bb;
        //cout<<a[i].xs<<" "<<a[i].zs<<endl;
        i++; 
    }
    int c=0;
    for(int j=0;j<i;j++)
    {
        if(a[j].zs>=1)
        {
            a[j].xs=a[j].xs*a[j].zs;
            a[j].zs=a[j].zs-1;
        }
        else
        {
            a[j].xs=0;
            a[j].zs=0;
            c++;
        }
    }
    int f=0;
    for(int j=0;j<i-c;j++)
    {
        f=1;
        j==0?cout<<a[j].xs<<" "<<a[j].zs:cout<<" "<<a[j].xs<<" "<<a[j].zs;    
    }
    if(f)
    cout<<endl;
    else
    cout<<"0 0"<<endl;
}

 

 posted on 2019-02-02 20:00  qmzhna  阅读(126)  评论(0编辑  收藏  举报