编程知识 cdmana.com

I don't understand why I do this and how I can't repeat it

img

#include<stdio.h>2int main()3{4    int n,x,y,z,i;5    scanf("%d,%d,%d,%d,%d",&n,&x,&y,&z,&i);6    i=0;7    z=0;8    for(int x=1;x<=(n/3);x++)9    {10        for(int y=0;y<x;y++)11        {12            z=(n-x-y)/2;13            if(2*z+x+y==n&&z>=x)14            {15                i++;16            }17        }18    }19    printf("%d",i);20    return 0;21}



Refer to the answer 1:

How to input so many , The title is to enter only one n

int main(){ int n,z,i=0; scanf("%d",&n); for(int x=1;x<=n/3;x++) { for(int y=1;y<=(n-x)/2;y++) { z=n-x-y; if(x+y>z) { i++; } } } printf("%d",i);}



Refer to the answer 2:



Refer to the answer 3:

Either side of the triangle is longer than the third side




Refer to the answer 4:

版权声明
本文为[CSDN Q & A]所创,转载请带上原文链接,感谢
https://cdmana.com/2021/10/20211029100305684Y.html

Scroll to Top