c语言回顾—练习
2018-01-24 14:51
176 查看
4.用结构体实现复数相加
![](https://img-blog.csdn.net/20180124135102191?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvRGFuaWVsRGluZ3NoZW5nbGk=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
5.编写一个程序输出它本身
int main()
{
FILE *fp;
char c;
fp=fopen(_FILE_,“r”);
do{
c=getc(fp);
putchar(c);
}while(c!=EOF);
fclose(fp);
return 0;
}
“`
![](https://img-blog.csdn.net/20180124144853934?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvRGFuaWVsRGluZ3NoZW5nbGk=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
6.
#include <stdio.h> typedef struct complex { float i; float j; }complex; int main(int argc, char const *argv[]) { complex a,b; printf("Please enter a complex:\n"); printf("Im="); scanf("%f",&a.i); printf("Re="); scanf("%f",&a.j); printf("Please enter one more complex:\n"); printf("Im="); scanf("%f",&b.i); printf("Re="); scanf("%f",&b.j); printf("Result:%.2f+%.2fi",a.i+b.i,a.j+b.j); return 0; }
5.编写一个程序输出它本身
int main()
{
FILE *fp;
char c;
fp=fopen(_FILE_,“r”);
do{
c=getc(fp);
putchar(c);
}while(c!=EOF);
fclose(fp);
return 0;
}
“`
6.
相关文章推荐