Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 我的程序忽略了';而';环_C - Fatal编程技术网

C 我的程序忽略了';而';环

C 我的程序忽略了';而';环,c,C,我需要做一个程序来计算3^2+6^2+9^2++(3×N)^2,对于用户给定的整数N。程序提示用户输入一个小于20的整数。程序应在3次错误机会后停止。这是我的代码: #include <stdio.h> int main(){ int n,x,i ; float p; printf("Hey give me a positive integer number smaller than 20 \n "); scanf("%

我需要做一个程序来计算3^2+6^2+9^2++(3×N)^2,对于用户给定的整数N。程序提示用户输入一个小于20的整数。程序应在3次错误机会后停止。这是我的代码:

#include <stdio.h>
int main(){
        int n,x,i ;
        float p;
        printf("Hey give me a positive integer number smaller than 20 \n ");
        scanf("%d" ,&n);
        x=3;
        p=0;
        while ((n<=0) && (n>=20)){
                printf("wrong input %d chances left \n" ,x);
                x--;
                if (x==0) return 0;
                scanf("%d" , &n);
        }
        for ( i=0; i<=n; i++){
                p= (3*i)* (3*i) + p ;
        }  
        printf("Yeah.. thats the result bro %f \n" , p);
        return 0;
}
#包括
int main(){
int n,x,i;
浮动p;
printf(“给我一个小于20的正整数”\n);
scanf(“%d”和“&n”);
x=3;
p=0;
而((n=20)){
printf(“输入错误%d\n”,x);
x--;
如果(x==0)返回0;
scanf(“%d”和“&n”);
}
对于(i=0;i
while ((n<=0) && (n>=20)){
while ((n<=0) || (n>=20)){