Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.93 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<time.h>
  3. #include<curl/curl.h>
  4.  
  5. int T1[100] = {};
  6.  
  7. int T2[10][10] = {};
  8. int T3[10][3] = {};
  9.  
  10. int code_value[10] = {};
  11.  
  12. int code_test[10] = {};
  13.  
  14.  
  15. void sort_table(int *array, int size)
  16. {
  17. int a, i, j;
  18. for (i=0; i<size; i++)
  19. {
  20. for(j=i; j<size; j++)
  21. {
  22. if(array[j]<array[i])
  23. {
  24. a = array[i];
  25. array[i] = array[j];
  26. array[j] = a;
  27. }
  28. }
  29.  
  30. }
  31. }
  32.  
  33. void sort_table_T3()
  34. {
  35. int i = 0;
  36. int j = 0;
  37. int x = 0;
  38. int k = 0;
  39. int n = 10;
  40. int temp = 0;
  41. for(i=0;i<n;i++)
  42. {
  43. for(j=i+1;j<n;j++)
  44. {
  45. if(T3[i][k] > T3[j][k])
  46. {
  47. for(x=0;x<3;x++) {
  48. temp=T3[i][x];
  49. T3[i][x]=T3[j][x];
  50. T3[j][x]=temp;
  51. }
  52. }
  53. }
  54. }
  55.  
  56.  
  57.  
  58. }
  59.  
  60. void generate_T1() {
  61. int T1_random = 0;
  62. int i = 0;
  63. for(i = 0; i<100; i++) {
  64. T1_random =rand()%(1000);
  65. T1[i] = T1_random;
  66. }
  67. sort_table(T1, 100);
  68. }
  69.  
  70. void generate_T2() {
  71.  
  72. int i = 1;
  73. int a = 1;
  74. for(i = 0; i < 10; i++) {
  75. for(a = 0; a < 10; a++) {
  76. T2[i][a] = T1[i*10 + a];
  77.  
  78. }
  79. }
  80. }
  81.  
  82. void generate_T3() {
  83. int i = 0;
  84. for(i = 0; i<10; i++) {
  85. generate_value_of_T3(i);
  86. }
  87.  
  88. }
  89.  
  90. int generate_value_of_T3(int i) {
  91.  
  92. int value1 =rand()%(10 - 1 + 1) + 1;
  93. int value2 =rand()%(10 - 1 + 1) + 1;
  94. if(value_exist_in_T3(value1, value2)) {
  95. generate_value_of_T3(i);
  96. } else {
  97.  
  98. T3[i][2] = T2[value1-1][value2-1];
  99. T3[i][0] = value1;
  100. T3[i][1] = value2;
  101. }
  102. }
  103.  
  104. int value_exist_in_T3(int value1, int value2) {
  105. int a = 0;
  106. int i = 0;
  107. for (a = 0; a < 10; a++)
  108. if(T3[a][0] == value1 && T3[a][1] == value2)
  109. return 1;
  110. return 0;
  111. }
  112.  
  113. void send_sms() {
  114.  
  115. CURL *curl;
  116. CURLcode res;
  117.  
  118. /* In windows, this will init the winsock stuff */
  119. curl_global_init(CURL_GLOBAL_ALL);
  120.  
  121. /* get a curl handle */
  122. curl = curl_easy_init();
  123. if(curl) {
  124. /* First set the URL that is about to receive our POST. This URL can
  125. just as well be a https:// URL if that is what should receive the
  126. data. */
  127. curl_easy_setopt(curl, CURLOPT_URL, "http://postit.example.com/moo.cgi");
  128. /* Now specify the POST data */
  129. curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "name=daniel&project=curl");
  130.  
  131. /* Perform the request, res will get the return code */
  132. res = curl_easy_perform(curl);
  133. /* Check for errors */
  134. if(res != CURLE_OK)
  135. fprintf(stderr, "curl_easy_perform() failed: %s\n",
  136. curl_easy_strerror(res));
  137.  
  138. /* always cleanup */
  139. curl_easy_cleanup(curl);
  140. }
  141. curl_global_cleanup();
  142. }
  143.  
  144. int main() {
  145. srand(time(NULL));
  146. generate_T1();
  147.  
  148. generate_T2();
  149.  
  150. generate_T3();
  151. sort_table_T3();
  152.  
  153. int i = 0;
  154. int a = 0;
  155. printf("Tableau T1");
  156. printf("\n");
  157. for(i = 0; i<100; i++) {
  158. printf("%d\t",T1[i]);
  159. }
  160.  
  161.  
  162. printf("\nTableau T3 (Cache a l'utilisateur)");
  163. printf("\n\tx\ty\tvalue");
  164.  
  165. int code = 0;
  166. for(i = 0; i<10; i++) {
  167. printf("\n\t");
  168. for(a = 0; a<3; a++)
  169. printf("%d\t",T3[i][a]);
  170. code_value[i] = T3[i][2];
  171. }
  172.  
  173.  
  174. printf("\nTableau T3 (Envoye Par SMS)");
  175. for(i = 0; i<10; i++) {
  176. printf("\n\t");
  177. for(a = 0; a<2; a++)
  178. printf("%d\t",T3[i][a]);
  179. }
  180.  
  181.  
  182. printf("\nTableau T2 (Pour trouver le code)");
  183. printf("\n\t");
  184. for(i = 0; i<10; i++) {
  185. printf("\n\t");
  186. for(a = 0; a<10; a++)
  187. printf("%d\t",T2[i][a]);
  188. }
  189. send_sms();
  190. printf("\nEntrez les codes avec le code recu par SMS et le tableau si dessus");
  191. int check = 0;
  192. for(i = 0; i < 10; i++){
  193. printf("\nCode %d :", i + 1);
  194. scanf("%d", &code_test[i]);
  195. }
  196. for(i = 0; i<10;i++)
  197. if(code_test[i] != code_value[i]) {
  198. return printf("\nLe code entre n'est pas bon");
  199. }else {
  200. return printf("\nLe code entre est bon");
  201. }
  202. return 0;
  203.  
  204.  
  205. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement