题目

解决代码及点评

根据题目要去,我们可以通过if实现该功能,伪代码如下:

if(a > 90) print 'A'

else if(a>80) print 'b'

else if(a>70) print 'c'

else if(a>60) print 'd'

else print 'e'

但是这道题我们希望考察switch,所以在解决代码中,我们使用了switch语句

#include <stdio.h>
#include <stdlib.h>
void main()
{
int a;
printf("please input a\n");
scanf_s("%d",&a); a=a/10; // a只取10位数,个位数忽略 switch (a)
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5: printf("E"); // 从10分到59分都是E,注意case0,1,2,3,4,5后面都没有break,也就是说上面五个条件全部执行这个分支
break;
case 6: // 当十位数是6时,打印d,下面的case类推
printf("D");
break;
case 7:
printf("C");
break;
case 8:
printf("B");
break;
case 9:
printf("A");
break; }
system("pause");
}

代码下载及其运行

代码下载链接:

http://download.csdn.net/detail/yincheng01/6640655

解压密码为c.itcast.cn

下载解压后用VS2013打开工程文件

点击 “本地Windows调试器” 执行

程序运行结果

等待用户输入百分制分数




基于visual Studio2013解决C语言竞赛题之0306分数转换的更多相关文章

  1. 基于visual Studio2013解决C语言竞赛题之0201温度转换

    题目 解决代码及点评 #include <stdio.h> #include <stdlib.h> void main() { float f; float c; float ...

  2. 基于visual Studio2013解决C语言竞赛题之1092链表转换

        题目 解决代码及点评 /************************************************************************/ /* ...

  3. 基于visual Studio2013解决C语言竞赛题之0401阶乘

      题目 解决代码及点评 这个是一道经典的教科书题目,基本上每本基础的c/c++语言教科书都会有这个题目 用来演示循环语句 #include <stdio.h> #include ...

  4. 基于visual Studio2013解决C语言竞赛题之0205位数求和

     题目

  5. 基于visual Studio2013解决C语言竞赛题之0409 100以内素数

       题目 解决代码及点评 在已经知道素数是怎么判断的基础上,增加循环,可以判断出100以内的素数 /******************************************* ...

  6. 基于visual Studio2013解决C语言竞赛题之0408素数

      题目 解决代码及点评 判断一个数是不是素数的方法,一般是看n是不是能被n以内的某个整数(1除外)整除 为了提高效率,这个整数范围一般缩小到n的平方根 如果在这个范围内的整数都不能整除,那么 ...

  7. 基于visual Studio2013解决C语言竞赛题之0407最大值最小值

      题目 解决代码及点评 这道题考察循环和比较 /*********************************************************************** ...

  8. 基于visual Studio2013解决C语言竞赛题之0406数列求和

      题目 解决代码及点评 这个题目,还是考察for循环的使用 以及数列规律,该数列的特点是第n个分子 = 第n-1个分子 + 第n-2个分子,分母也是此规律 而另外一个规律是第n个分子和第n- ...

  9. 基于visual Studio2013解决C语言竞赛题之0405阶乘求和

      题目 解决代码及点评 这道题和上一道题类似,第n个累加项 = n-1累加项的n倍 由于有这个规律,我们可以用一个for循环实现 但是例子代码并没有这么做,大家可以回去修改下代码,使得代码更 ...

随机推荐

  1. Insert into a Cyclic Sorted List

    Given a node from a cyclic linked list which has been sorted, write a function to insert a value int ...

  2. 如何实现HTTPSERVER

    Write your own http server author : Kevin Lynx Why write your own? 看这个问题的人证明你知道什么是http server,世界上有很多 ...

  3. 调不尽的内存泄漏,用不完的Valgrind

    调不尽的内存泄漏,用不完的Valgrind Valgrind 安装 1. 到www.valgrind.org下载最新版valgrind-X.X.X.tar.bz2 2. 解压安装包:tar –jxvf ...

  4. Apache proxy中转设置

    参考http://sjsky.iteye.com/blog/1067119 打开http.conf  (macOS中 Apache配置文件在/etc/apache2/中   etc是隐藏的) 确保下面 ...

  5. chrome extension overview

    目录 什么是扩展............................................................................................ ...

  6. Round B APAC Test 2017

    https://code.google.com/codejam/contest/5254487 A. Sherlock and Parentheses Problem Sherlock and Wat ...

  7. Java解析器

    http://www.infoq.com/cn/articles/HIgh-Performance-Parsers-in-Java-V2?utm_source=infoq&utm_medium ...

  8. HDU 2673 shǎ崽 OrOrOrOrz

    #include <cstdio> #include <algorithm> using namespace std; int main() { int n; while (s ...

  9. HDU 1551 Cable master

    题解:很显然的二分检索,在算法艺术上看过原题,不过这里要注意精度: #include <cstdio> int n,m; ]; bool test(double x){ ,i; ;i< ...

  10. HDU2795 billboard【转化为线段树。】

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2795 hhanger大神的题目,水题都得有点思维. 题意:h*w的木板,放进一些1*L的物品,求每次放 ...