标题:刚学c++ 有几个题目不会做了
只看楼主
zzz928101
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2008-11-16
得分:0 
第三道题目:
#include <iostream>
using namespace std;

main()
{
    int no=0;
    int ne=0;
    int i;
    int a[5]={1,2,3,4,5};
    int o[5];
    int e[5];

    for(i=0;i<5;i++)
    {
        a[i]%2==1?o[no++]=a[i]:e[ne++]=a[i];
    }
    cout<<"the odd is:";
    for(i=0;i<no;i++)
      cout<<o[i]<<endl;
    cout<<"the even is:";
    for(i=0;i<ne;i++)
       cout<<e[i]<<endl;
}
2008-11-19 16:38
goushuangquan
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2008-11-19
得分:0 
第一个题目:
#include <iostream>
using namespace std;
int main()
{
    int a,c,b=0;
    cin>>a;
    while(true)
    {
        c=a;
        while(a>=10)
        {
           b=b*10+a%10;
           a=a/10;
        }
        if(a<10)
        {
            b=b*10+a;
        }
        if(b==c)
        {
            cout<<"error!"<<endl;
        }
        else
        {
           cout<<b<<endl;
        }
        b=0;  
        cin>>a;
    }
   
   
   
}
2008-11-19 17:08



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-242730-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.087512 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved