#include <stdio.h>
int main(void) {
int t,i;
scanf("%d",&t);
while(t–){
int n,count=0;
scanf("%d",&n);
for(i=1;i<=n;i++){
int sum;
sum=ii;
if(sum>n){
int b,s;
s=(i-1) (i-1);
count++;
b=(n-s);
i=1;
n=b;
}
else if(n==3){
count=count+3;}
else if(n==2){
count=count+2;}
else if(n==1){
count=count+1;}
}
printf("%d\n",count);
}
return 0;
}
1 Like
ssjgz
March 26, 2021, 6:30pm
2
Please either format your code or (better!) link to your submission - the forum software has mangled it and it won’t compile!
Also, what input are you testing it with?
2 Likes
so the program work perfectly when only " if " statement is working (which is for like 20 or 85 input)
but it start to show problem when i use input like 10 or 114 which require " else if " statement use,
Problem code is ICL1902 .
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int
main (void)
{
int t, i;
char sum;
scanf ("%d", &t);
while (“t-”)
{
int n, count = 0;
scanf ("%d", &n);
for (i = 1; i <= n; i++)
{
char sum;
sum = i++;
if (sum > n)
{
int b, s;
s = (i - 1)*(i - 1);
count++;
b = (n - s);
i = 1;
n = b;
}
else if (n == 3)
{
count = count + 3;
}
else if (n == 2)
{
count = count + 2;
}
else if (n == 1)
{
count = count + 1;
}
}
printf ("you problem has solve now to updat can code%f\n", &count);
}
return 0;
}