//============================================================================ // Name : Test02.cpp // Author : peterli // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include <stdio.h> #include <stdlib.h> struct circuit { char yjtype; int number; int startnode; int endnode; int control; double argument; }; // void flush() { char temp; while((temp = getchar()) != '\n' && temp != EOF); } int main() { int numNode = 0; int i = 0; double tempDouble = 0.0l; printf("please input the number of node:\nnumNode ="); _flushall(); scanf("%d",&numNode); struct circuit* node = (struct circuit*)calloc(numNode,sizeof(struct circuit)); for(i = 0; i < numNode; i++) { printf("the %dth Node\n",i+1); _flushall(); printf("Node.yjtype: "); _flushall(); scanf("%c",&node[i].yjtype); printf("Node.number: "); _flushall(); scanf("%d",&node[i].number); printf("Node.startnode: "); _flushall(); scanf("%d",&node[i].startnode); printf("Node.endnode: "); _flushall(); scanf("%d",&node[i].endnode); printf("Node.control: "); _flushall(); scanf("%d",&node[i].control); printf("Node.argument: "); _flushall(); scanf("%lf",&node[i].argument); //scanf("%lf",&tempDouble); //node[i].argument = tempDouble; } for(i = 0; i < numNode; i++) { printf("\nthe %dth Node\n",i+1); printf("Node.yjtype:%c\n ",node[i].yjtype); printf("Node.number:%d\n",node[i].number); printf("Node.startnode:%d\n",node[i].startnode); printf("Node.endnode:%d\n",node[i].endnode); printf("Node.control:%d\n",node[i].control); printf("Node.argument:%f\n",node[i].argument); _flushall(); } return 0; }