-
Notifications
You must be signed in to change notification settings - Fork 0
/
24.cpp
52 lines (49 loc) · 741 Bytes
/
24.cpp
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
//
// Main.c
// Homework
//
// Created by EilotDaniel on 12/30/15.
// Copyright © 2015 GeniusV. All rights reserved.
//
#include<stdio.h>
#include<math.h>
int find (char a[], char x);
int main ()
{
char a[100];
char x;
int i = 0;
while (1)
{
scanf ("%c", &a[i]);
if (a[i] == '\n')
{
break;
}
i ++;
}
printf("x = ");
scanf ("%c", &x);
printf ("The Num = %d \n", find (a, x));
return 0;
}
int find (char a[], char x)
{
int ct = 0, i = 0;
while (a[i] != '\0')
{
if (a[i] == x)
{
ct ++;
}
i ++;
}
if (ct == 0)
{
return 0;
}
else
{
return ct;
}
}