题目11 奇偶数分离

来源:互联网 发布:淘宝打包员一天多少单 编辑:程序博客网 时间:2024/06/05 05:32

    已AC代码:

 #include<cstdio>#include<algorithm>void parity(int a[], int b[]){    int c=1;    for(int i=0; i<5555; i++)    {        a[i] = c;        c += 2;    }    c = 2;    for(int i=0; i<5555; i++)    {        b[i] = c;        c += 2;    }}int main(){    int t, a[5555], b[5555];    scanf("%d", &t);    parity(a, b);    while(t--)    {        int temp;        scanf("%d", &temp);        for(int i=0; a[i] < temp; i++)        {            printf("%d ", a[i]);        }        printf("\n");        for(int i=0; b[i] <= temp; i++)        {            printf("%d ", b[i]);        }        printf("\n");    }}        


0 0
原创粉丝点击