想不明白呀?求大佬告知
#include<stdio.h>//static int s;//为什么放在这里可以
int main()
{
int i,n,s;
scanf("%d",&n);
for(i=1;i<n;i++)
{
if((i%3==0)&&(i%5==0))
{ static s=0;//为什么static在这时下面的输出的s是乱码
printf("%d,",i);
s=s+1;
}
}
printf("=>共%d个数满足条件\n",s);
}
for(int i=0;i<10;i++) printf("this is i:%d",i); printf("this is not i:%d",i);
[此贴子已经被作者于2020-6-22 01:23编辑过]
#include <stdio.h> int main( void ) { unsigned n; scanf( "%u", &n ); unsigned s = 0; for( unsigned i=1; i!=n; ++i ) { if( i%3==0 && i%5==0 ) { printf( "%u,", i ); ++s; } } printf( " => 共%u个数满足条件\n", s ); }