标签:scanf pre return def while main define 结构 color
4 5 6 9 6 8 9 3 5 5 5 5 9 8 7 6 5 10 1 2 3 4 5 5 4 2 1 3
6 9 8 5 9 8 7 6 5 1 2 3 4 5
1 #include<iostream> 2 #include<stdio.h> 3 #define listMax 100000 4 5 using namespace std; 6 7 typedef int element; 8 typedef struct{ 9 element *elem; 10 int length; 11 int listSize; 12 }Elemlist; 13 14 void creat(Elemlist &L,int n){ 15 L.elem = new int[listMax]; 16 L.length = n; 17 L.listSize = listMax; 18 } 19 20 void input(Elemlist &L){ 21 int i; 22 for(i = 0 ; i < L.length;i++){ 23 scanf("%d",&L.elem[i]); 24 } 25 } 26 27 void del(Elemlist &L,int j){ 28 int i; 29 for(i = j ; i < L.length;i++){ 30 L.elem[i] = L.elem[i + 1]; 31 } 32 L.length--; 33 } 34 35 void compare(Elemlist &L){ 36 int i,j; 37 for(i = 0; i < L.length - 1;i++){ 38 for(j = i + 1;j < L.length; j++){ 39 if(L.elem[i] == L.elem[j]){ 40 del(L,j); 41 j--; 42 } 43 } 44 } 45 } 46 47 void output(Elemlist &L){ 48 int i; 49 for(i = 0; i < L.length - 1;i++){ 50 printf("%d ",L.elem[i]); 51 } 52 printf("%d\n",L.elem[i]); 53 } 54 55 int main(){ 56 Elemlist L; 57 int a,b; 58 scanf("%d",&a); 59 while(a--){ 60 scanf("%d",&b); 61 creat(L,b); 62 input(L); 63 compare(L); 64 output(L); 65 } 66 return 0; 67 }
标签:scanf pre return def while main define 结构 color
原文地址:https://www.cnblogs.com/xiaolitongxueyaoshangjin/p/12584062.html