输出字符串中个位数小于六的数
#include <stdio.h>
void PRINT(long s)
{
FILE *out;
printf("s=%ld\n",s);
if((out=fopen("result.dat","w+"))!=NULL)
{
fprintf(out,"s=%ld",s);
fclose(out);
}
}
main()
{
int a[50]={3421,3834,3124,3349,2842,2384,3459,2338,2348,7234,6482,4823,4829,5234,8449,2042,7383,2438,4592,8343,8342,7234,9432,8432,
8842,8812,4324,7724,7345,9134,7442,7524,6732,7752,7692,1384,2343,8249,7235,7731,7525,6259,2385,7525,6323,7525,7534,8535,7563,7534};
/*考生在此设计程序*/
int i,sum=0;
for(i=0;i<50;i++)
{
if(a[i]%10<6)
sum=sum+a[i];
}
PRINT(sum);
}
本文来自博客园,作者:JackieDYH,转载请注明原文链接:https://www.cnblogs.com/JackieDYH/p/17635002.html