1、1、正余弦计算#include“stdio.h“#include“math.h“double sincos(double x,double *cs);void main()double n,sinx,cosx;printf(“?n:“);scanf(“%lf“,sinx=sincos(n,printf(“sinx=%lf,cosx=%lfn“,sinx,cosx);double sincos(double x,double *cs)double sx;x=x*3.14159265/180;*cs=cos(x);sx=sin(x);return sx;二、#include“stdio.h“voi
2、d main()void ex(int v4);int a44=1,2,2,3,4,3,4,5,6,7;int i,j;ex(a);for(i=0;i#include void main() int a,b,num,i,k;printf(“Input a scanf(“%d,%d“,for(num=a;numk)printf(“%d is a prime number.n“,num); 五、水仙花数/*Name:ex02-26.cpp*/#include“stdio.h“void main()int num,a,b,c;for(num=100;num=1;i-)y=y+f(i);printf(
3、“y=%5.1fn“,y);九、/* Name: ex06-09.cpp */#include void main() int stu1=78,98,73,-1,stu2=100,98,-1,stu3=88,-1,stu4=100,78,33,65,-1,stu5=99,88,-1;int *grad=stu1,stu2,stu3,stu4,stu5,*p=grad,i;for(i=1;i=0) /*当取出的数组元素值不是-1 时*/ printf(“%4d“,*p);(*p)+; /*指针变量*p 移动指向当前数组的下一个数组元素*/p+; /*指针变量 p 移动指向下一个指针数组元素(即下
4、一个一维数组)*/printf(“n“);十、结构体#include“stdio.h“struct Tint x;char c;void main()void f(struct T b);struct T a=110,z;f(a);printf(“%d,%cn“,a.x,a.c);void f(struct T b)b.x=20;b.c=y;十一、#include“stdio.h“void main()FILE *fp;int c1,c2,c3,c4;char c;c1=c2=c3=c4=0;if(fp=fopen(“mydata.txt“,“r“)=NULL)printf(“Cant open the file.n“);return;c=fgetc(fp);while(c!=EOF)c1=c1+1;if(c=Aprintf(“%dn“,c);for(c=a;c+=0printf(“c=%dn“,c);