(算法练习)——1295. 统计位数为偶数的数字

要求:
https://leetcode-cn.com/problems/find-numbers-with-even-number-of-digits/comments/
说明:
emmmget了它的答题方式,提交也通过了
代码:

#include <stdio.h>
#include <string.h>

int main(){
	int record[100];
	int i = 0;
	while(scanf("%d",&record[i]) != EOF){
		i++;
		if(getchar() == '\n'){
			int signal = 0;
			for(int j = 0;j <i;j++){
				int count = 0;
				while((record[j] / 10)>=1){
					record[j] = record[j] / 10;
					count++;
				}
				if(count %2==1){
					signal++;
				}
			}
			printf("%d\n",signal);
			memset(record,0,sizeof(record));
		}
	}
}
发布了104 篇原创文章 · 获赞 3 · 访问量 1946

猜你喜欢

转载自blog.csdn.net/weixin_42377217/article/details/104033005