C 我的程序忽略了';而';环
我需要做一个程序来计算3^2+6^2+9^2++(3×N)^2,对于用户给定的整数N。程序提示用户输入一个小于20的整数。程序应在3次错误机会后停止。这是我的代码: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("%
#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)){