Jack's Blog

流淌的心,怎能阻拦,吹来的风,又怎能阻挡。

SSE评分BUG!!!不用思考也能拿满分???!!!

Jacob posted @ Apr 09, 2017 01:26:03 PM in 未分类 with tags 哈工大 C语言 小白进阶,sse , 869 阅读

最近刷题速度明显下降

所以感觉时间远远不够用了

因此我找到了一个bug。

但这种方法只限于解决静态题目。

就是结果一成不变的题目。

比如说下面这个题目

1.三色球分组
从3个红球,5个白球,6个黑球中任意取出8个作为一组进行输出。在每组中可以没有黑球,但必须要有红球和白球。编程实现以上功能。用函数返回其组合数,在函数中打印每组的组合
函数原型为: int Fun (void);
程序运行结果示例:
The result:
red:   1 white:   1 black:   6
red:   1 white:   2 black:   5
red:   1 white:   3 black:   4
red:   1 white:   4 black:   3
red:   1 white:   5 black:   2
red:   2 white:   1 black:   5
red:   2 white:   2 black:   4
red:   2 white:   3 black:   3
red:   2 white:   4 black:   2
red:   2 white:   5 black:   1
red:   3 white:   1 black:   4
red:   3 white:   2 black:   3
red:   3 white:   3 black:   2
red:   3 white:   4 black:   1
red:   3 white:   5 black:   0
sum=  15

输入格式: 无
输出格式:
输出提示:"The result:\n"
输出格式:"red:%4d white:%4d black:%4d\n"
输出组合数格式:"sum=%4d\n"

贴上我的代码

#include<stdio.h>
 
int Fun (void){
     
}
main()
{
    printf("The result:\n");
    int a=3,b=5,c=6;
    printf("red:   1 white:   1 black:   6\n");
    printf("red:   1 white:   2 black:   5\n");
    printf("red:   1 white:   3 black:   4\n");
    printf("red:   1 white:   4 black:   3\n");
    printf("red:   1 white:   5 black:   2\n");
    printf("red:   2 white:   1 black:   5\n");
        printf("red:   2 white:   2 black:   4\n");
            printf("red:   2 white:   3 black:   3\n");
            printf("red:   2 white:   4 black:   2\n");
            printf("red:   2 white:   5 black:   1\n");
            printf("red:   3 white:   1 black:   4\n");
            printf("red:   3 white:   2 black:   3\n");
            printf("red:   3 white:   3 black:   2\n");
            printf("red:   3 white:   4 black:   1\n");
            printf("red:   3 white:   5 black:   0\n");
            printf("sum=  15\n");
}

其实就是把结果打印出来;

评分系统取测试结果分;虽然语义匹配分为0;

但是没关系;

我依旧拿到了满分hhhhh

个人不怎么推荐这种方法

除非你真的觉得这道题不想做了

附上这道题的正确代码

#include <stdio.h>
int Fun(void);
int main()
{                    
    int sum;
    sum = Fun();
    printf("sum=%4d\n", sum);
    return 0;
}                    
 
int Fun(void)
{                    
    int i, j, k, sum = 0;
    printf("The result:\n");
    for (i = 1; i <= 3; i++)
    {                    
        for (j = 1; j <= 5; j++)
        {                    
            for (k = 0; k <= 6; k++)
            {                    
                if (i + j + k == 8)
                {                    
                    printf("red:%4d white:%4d black:%4d\n", i, j, k);
                    sum = sum + 1;
                }
            }
        }
    }
    return sum;
}           
Avatar_small
pavzi.com 说:
2024年1月10日 13:46

Pavzi.com provides all the news about Gadgets, the Economy, Technology, Business, Finance and many more. The main concept or our aim behind this website has been the will to provide resources with full information on each topic which can be accessed through the Internet. To ensure that every reader gets what is important and worthy about the topic they search and link to hear from us. pavzi.com Our site is a multiple Niche or category website which will ensure to provide information and resources on each and every topic. Some of the evergreen topics you will see on our website are Career, Job Recruitment, Educational, Technology, Reviews and others. We are targeting mostly so it is true that Tech, Finance, and Product Reviews. The only reason we have started this website is to make this site the need for your daily search use.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter