| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 510 人关注过本帖
标题:谁帮忙改一下呀!!!!!!!!!!!!!!!!!
只看楼主 加入收藏
wcp126
Rank: 1
等 级:等待验证会员
帖 子:95
专家分:7
注 册:2010-3-30
结帖率:90.91%
收藏
 问题点数:0 回复次数:7 
谁帮忙改一下呀!!!!!!!!!!!!!!!!!
图片附件: 游客没有浏览图片的权限,请 登录注册
using System;
public class bijiao
{
    private double[] a = new double[10];
    private double[] b = new double[10];

    public bijiao()
    {
        Console.WriteLine("请输入数组a的值");
        for (int i = 0; i <= 9; i++)
        {
            Console.WriteLine("a[" + i + "]=");
            a[i] = double.Parse(Console.ReadLine());
        }
        Console.WriteLine("请输入数组b的值");
        for (int k = 0; k <= 9; k++)
        {
            Console.WriteLine("b[" + k + "]=");
            b[k] = double.Parse(Console.ReadLine());
        }
      
    }
    void fangfa()
    {
        String str = "";
        if (a[i] == b[k])
        {
            str = string.Format("a[" + i + "]=b[" + k + "]={0}", a[i]);
            Console.WriteLine(str);
        }     
    }
  public static void Main()
    {
        bijiao b1 = new bijiao();
        b1.fangfa();
    }
}
搜索更多相关主题的帖子: private public double 
2010-04-05 16:36
qubo1982
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:1
帖 子:367
专家分:1132
注 册:2009-3-18
收藏
得分:0 
程序代码:
    public class bijiao
    {
        private double[] a = new double[10];
        private double[] b = new double[10];
       
        int i, k;

        public bijiao()
        {
            Console.WriteLine("请输入数组a的值");
            for (i = 0; i <= 9; i++)
            {
                Console.WriteLine("a[" + i + "]=");
                a[i] = double.Parse(Console.ReadLine());
            }
            Console.WriteLine("请输入数组b的值");
            for (k = 0; k <= 9; k++)
            {
                Console.WriteLine("b[" + k + "]=");
                b[k] = double.Parse(Console.ReadLine());
            }

        }

        void fangfa(int i, int k)
        {
            String str = "";
            if (a[i] == b[k])
            {
                str = string.Format("a[" + i + "]=b[" + k + "]={0}", a[i]);
                Console.WriteLine(str);
            }
        }
        public static void Main()
        {
            bijiao b1 = new bijiao();
            b1.fangfa(b1.i, b1.k);
        }
    }
2010-04-05 16:40
qubo1982
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:1
帖 子:367
专家分:1132
注 册:2009-3-18
收藏
得分:0 
不过,这段代码有啥意思呢,i 和 k 的值肯定都是10啊,而且运行到 if (a[i] == b[k]) 肯定是要出错的
2010-04-05 16:46
chenkb730
Rank: 2
等 级:论坛游民
帖 子:39
专家分:44
注 册:2010-3-22
收藏
得分:0 
using System;
public class bijiao
{
    private double[] a = new double[10];
    private double[] b = new double[10];
    int i = 0, k = 0;
    public bijiao()
    {
        Console.WriteLine("请输入数组a的值");
        for (int i = 0; i <= 9; i++)
        {
            Console.WriteLine("a[" + i + "]=");
            a[i] = double.Parse(Console.ReadLine());
        }
        Console.WriteLine("请输入数组b的值");
        for (int k = 0; k <= 9; k++)
        {
            Console.WriteLine("b[" + k + "]=");
            b[k] = double.Parse(Console.ReadLine());
        }

    }
    void fangfa()
    {
        String str = "";
        for (int i = 0; i <= 2; i++)
        {
            for (int k = 0; k <= 2; k++)
                if (a[i] == b[k])
                {
                    str = string.Format("a[" + i + "]=b[" + k + "]={0}", a[i]);
                    Console.WriteLine(str);
                }
        }
    }
    public static void Main()
    {
        bijiao b1 = new bijiao();
        b1.fangfa();
        Console.ReadLine();
    }
}
就是这样子啦!!!
2010-04-05 17:02
wcp126
Rank: 1
等 级:等待验证会员
帖 子:95
专家分:7
注 册:2010-3-30
收藏
得分:0 
回复 4楼 chenkb730
没有结果呀 大哥!!!!!!!!
2010-04-05 17:16
wcp126
Rank: 1
等 级:等待验证会员
帖 子:95
专家分:7
注 册:2010-3-30
收藏
得分:0 
回复 2楼 qubo1982
谢了!!!!!!!!!!1
2010-04-05 17:20
玄风
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-4-5
收藏
得分:0 
是求相同的元素吧,那就是这样啦
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        public class bijiao
        {
            private double[] a = new double[10];
            private double[] b = new double[10];

            public bijiao()
            {
                Console.WriteLine("请输入数组a的值");
                for (int i = 0; i <= 9; i++)
                {
                    Console.Write("a[" + i + "]=");
                    a[i] = double.Parse(Console.ReadLine());
                }
                Console.WriteLine("请输入数组b的值");
                for (int k = 0; k <= 9; k++)
                {
                    Console.Write("b[" + k + "]=");
                    b[k] = double.Parse(Console.ReadLine());
                }

            }
         public    void fangfa()
            {
                String str;
                for (int i=0;i<=9;i++)
                if (a[i] == b[i])
                {
                    str = string.Format("a[" + i + "]=b[" + i + "]={0}", a[i]);
                    Console.WriteLine(str);
                }
            }
            static void Main(string[] args)
            {
                bijiao b1 = new bijiao();
                b1.fangfa();


            }

        }
    }
}
2010-04-05 20:11
chenkb730
Rank: 2
等 级:论坛游民
帖 子:39
专家分:44
注 册:2010-3-22
收藏
得分:0 
怎么会没结果呢,我可是调试过的阿
2010-04-06 10:11
快速回复:谁帮忙改一下呀!!!!!!!!!!!!!!!!!
数据加载中...
 
   



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

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