标题:visual studio 2010求解
只看楼主
xiaohong1111
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2013-12-25
结帖率:0
已结贴  问题点数:20 回复次数:2 
visual studio 2010求解
在C语言中学过的比如printf,scanf语句,在用visual studio 2010时该怎么变换啊,大家帮帮忙。。。比如在几个数比较大小的时候,在C语言中一开始是scanf("%f,%f,%f"&a,&b,&c);
最后是printf("%5.2f,%5.2f,%5.2f\n",a,b,c)中间的比较过程我都会,就是不懂在visual studio中这两条语句怎么变换才能输出想要的结果。
搜索更多相关主题的帖子: visual C语言 中学 
2013-12-25 11:08
梁歌love
Rank: 2
等 级:论坛游民
帖 子:14
专家分:29
注 册:2013-4-1
得分:20 
当排序的数少的时候,比如说3个,可以用这种排序法
               int a, b, c, t=0;                           
               if (a < b)                                //本条件语句实现a>=b
                 {   t = a;    a = b;   b = t;   }
               if  (a < c)                               //本条件语句实现a>=c
                  {   t = a;   a = c;     c = t;   }
               if  (b < c)                               //本条件语句实现b>=c
                  {   t = b;   b = c;     c = t;   }
               Console.WriteLine("排序结果为:   {0},{1},{2}",a,b,c);

还有就是可以用数组冒泡法排序。比如十个数排序
           int[] a = new int[11];
            int i, j, t, min, temp;
            Console.WriteLine("input 10 numbers :\n");
            for (i = 1; i < 11; i++)
                a[i] = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("当前数据个数已经全部输入完毕!");
            Console.WriteLine();
           
              for(j=1;j<=9;j++)
               for(i=1;i<=10-j;i++)
                if(a[i]>a[i+1])
                {
                    t=a[i];
                    a[i]=a[i+1];
                    a[i+1]=t;
                }   
//输出排序结果               
 for (i = 1; i < 11; i++)
                Console.WriteLine("{0}", a[i]);
            Console.ReadLine();

希望看不见,并不意味着不存在。
2013-12-26 20:17
梁歌love
Rank: 2
等 级:论坛游民
帖 子:14
专家分:29
注 册:2013-4-1
得分:0 
当排序的数少的时候,比如说3个,可以用这种排序法
               int a, b, c, t=0;                           
               if (a < b)                                //本条件语句实现a>=b
                 {   t = a;    a = b;   b = t;   }
               if  (a < c)                               //本条件语句实现a>=c
                  {   t = a;   a = c;     c = t;   }
               if  (b < c)                               //本条件语句实现b>=c
                  {   t = b;   b = c;     c = t;   }
               Console.WriteLine("排序结果为:   {0},{1},{2}",a,b,c);

还有就是可以用数组冒泡法排序。比如十个数排序
           int[] a = new int[11];
            int i, j, t, min, temp;
            Console.WriteLine("input 10 numbers :\n");
            for (i = 1; i < 11; i++)
                a[i] = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("当前数据个数已经全部输入完毕!");
            Console.WriteLine();
           
              for(j=1;j<=9;j++)
               for(i=1;i<=10-j;i++)
                if(a[i]>a[i+1])
                {
                    t=a[i];
                    a[i]=a[i+1];
                    a[i+1]=t;
                }   
//输出排序结果               
 for (i = 1; i < 11; i++)
                Console.WriteLine("{0}", a[i]);
            Console.ReadLine();

希望看不见,并不意味着不存在。
2013-12-26 20:18



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




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

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