1 #include <stdio.h>
2 #include<conio.h>
3 #include <iostream>
4 #include <string.h>
5 void main()
6 {
7 int i,j,k,count;
8 char s1[100],s2[100];
9 printf("Please enter main string:");
10 gets(s1);
11 printf("enter sub string:");
12 gets(s2);
13 count=0;
14 for(i=0;s1[i]!='\0';i++)
15 {
16 for(k=0,j=0;(s1[j]==s2[k])&&(s1[j]!='\0');j++,k++);
17 if(s2[k]=='\0')
18 count++;
19 }
20 printf("\ncount=%d\n",count);
21 }
22 //--------------
23 #include<iostream>
24 using namespace std;
25 double fun(double x,int n)
26 {
27 double m1=1,sum=1;
28 for(int i=1;i<=n;i++)
29 if(i%2==1)
30 {
31 for(int j=2*i;j>0;j--)
32 m1*=x/j;
33 sum+=-m1;
34 }
35 else
36 {
37 for(int j=2*i;j>0;j--)
38 m1*=x/j;
39 sum+=m1;
40 }
41 return sum;
42 }
43 int main()
44 {
45 int x,n;
46 cout<<"Please input x:"<<endl;
47 cin>>x;
48 cout<<"Please input n:"<<endl;
49 cin>>n;
50 cout<<fun(x,n)<<endl;
51 }