| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 528 人关注过本帖
标题:运行有问题,找错
取消只看楼主 加入收藏
韩学敏
Rank: 2
等 级:论坛游民
帖 子:52
专家分:26
注 册:2012-11-3
结帖率:82.35%
收藏
 问题点数:0 回复次数:1 
运行有问题,找错
#include<iostream.h>
void main()
{
    char a[8],b[8];

    int i=0,j=0;
    cout<<"please input a:";
    do
    {
        cin>>a[i];
    }while(a[i]!='\n');
    cout<<"please input b:";
    do
    {
        cin>>b[i];
    }while(b[i]!='\n');
        
    if(a[0]==b[0])
        cout<<"they are equal!"<<endl;
    else if(a[0]=='r'&&b[0]=='s')
        cout<<"the winner is a!"<<endl;
    else if(a[0]=='r'&&b[0]=='c')
        cout<<"the winner is b!"<<endl;
    else if(a[0]=='c'&&b[0]=='s')
        cout<<"the winner is b!"<<endl;
    else if(a[0]=='c'&&b[0]=='r')
        cout<<"the winner is a!"<<endl;
    else if(a[0]=='s'&&b[0]=='r')
        cout<<"the winner is b!"<<endl;
    else if(a[0]=='s'&&b[0]=='c')
        cout<<"the winner is a!"<<endl;
}
红色字输出不了,前面的赋值也不成功,求解释
搜索更多相关主题的帖子: please include 
2013-09-24 19:28
韩学敏
Rank: 2
等 级:论坛游民
帖 子:52
专家分:26
注 册:2012-11-3
收藏
得分:0 
回复 3楼 fxbszj
#include<iostream.h>
void main()
{
    char a[8],b[8];
    int i=0,j=0;



    cout<<"please input a:";
    cin>>a[i];
    while(a[i]!='\n')
    {
        i++;
        cin>>a[i];
    }
    cout<<"please input b:";
    cin>>b[j];
    while(b[j]!='\n')
    {
        j++;
        cin>>b[j];
    }


        
    if(a[0]==b[0])
        cout<<"they are equal!"<<endl;
    else if(a[0]=='r'&&b[0]=='s')
        cout<<"the winner is a!"<<endl;
    else if(a[0]=='r'&&b[0]=='c')
        cout<<"the winner is b!"<<endl;
    else if(a[0]=='c'&&b[0]=='s')
        cout<<"the winner is b!"<<endl;
    else if(a[0]=='c'&&b[0]=='r')
        cout<<"the winner is a!"<<endl;
    else if(a[0]=='s'&&b[0]=='r')
        cout<<"the winner is b!"<<endl;
    else if(a[0]=='s'&&b[0]=='c')
        cout<<"the winner is a!"<<endl;
}
很不好意思,我改了一下,还是不行,能不能帮忙再看看,谢谢了。。
2013-09-25 19:09
快速回复:运行有问题,找错
数据加载中...
 
   



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

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