1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
// t3.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "stdio.h"
#include <stdlib.h>
#include<math.h>
#include<time.h>
#define maxn 10000000 +10
char s[maxn];
int main()
{
//题目1 统计个数
/*int count =0;
int temp;
while (~scanf_s("%d", &temp))
{
count++;
}
printf_s("%d", count);*/ //显示不出来
//输入一些数,求最大值、最小值和平均数
//int min, max, n, sum,count = 0;
//float avg;
//scanf_s("%d", &n);
//max = n;
//min = n;
//sum = n;
//count++;
//while (scanf_s("%d", &n)!=EOF)
//{
// count++;
// sum += n;
// if (n > max)
// max = n;
// if (n < min)
// min = n;
//}
//avg = sum*1.0 / count;
//printf_s("%d %d %f\n", max,min,avg);
//5.输入一些数 ,求出他们的方差
/*double ave, sum = 0, varance, psum = 0;
int n.a[110], count = 0;
while (scanf_s("%d", &n) != EOF)
{
a[count++] = n;
sum += n;
}
avg = sum*1.0 / count;
for (int i = 0; i < count; i++)
psum += (a[i] - ave)*(a[i] - ave);
variance = psum / count;
print("%lf", variance);*/
scanf_s("%s", s);
int tot = 0;
for (int i = 0;s[i]; i++) {
if (s[i] == '1') tot++;
}
printf_s("%d\n", tot);
system("pause");
return 0;
}
|