1 #include <stdio.h> 2 3 typedef struct node 4 { 5 int value = 0; 6 struct node * pleft; 7 struct node * pright; 8 }Node; 9 struct node * head; 10 void insertTree(int temp, struct node * p) 11 { 12 if(p->value == 0) 13 p->value = temp; 14 else if(temp>p->value) 15 { 16 //p->pright = new (Node *); 17 insertTree(temp, p->pright); 18 } 19 else if(temp<p->value) 20 { 21 //p->pleft = new (* Node); 22 insertTree(temp, p->pleft); 23 } 24 } 25 26 void printTree(Node * p) 27 { 28 if(p->pleft!=NULL) printTree(p->pleft); 29 printf("%d", p->value); 30 if(p->pright!=NULL) printTree(p->pright); 31 } 32 33 int main(void) 34 { 35 int n; 36 //int inputArray[1000]; 37 //int OutputArray[1000]; 38 39 //head.value = 0; 40 int temp; 41 42 scanf("%d", &n); 43 for(int i=0; i<n; i++) 44 { 45 scanf("%d", &temp); 46 if(i==0) 47 head->value = temp; 48 insertTree(temp, head); 49 } 50 //scanf("%d", &inputArray[i]); 51 printTree(head); 52 53 return 0; 54 }
#include <stdio.h> int main(void) { char inputstr[100]; gets(inputstr); int result = 0; int i = 2; while(inputstr[i]!=‘\0‘) { // int temp = inputstr[i]-‘0‘; // if(inputstr[i]>=‘A‘) // temp -= 7; switch(inputstr[i]) { case ‘F‘:result = result*16+15;break; case ‘E‘:result = result*16+14;break; case ‘D‘:result = result*16+13;break; case ‘C‘:result = result*16+12;break; case ‘B‘:result = result*16+11;break; case ‘A‘:result = result*16+10;break; default: result = result*16 + (inputstr[i]-‘0‘); } // result = result*16 + temp; i++; } printf("%d",result); return 0; }
原文:http://www.cnblogs.com/LideAiYaner-1wn/p/5300955.html