Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<time.h>
- #include<curl/curl.h>
- int T1[100] = {};
- int T2[10][10] = {};
- int T3[10][3] = {};
- int code_value[10] = {};
- int code_test[10] = {};
- void sort_table(int *array, int size)
- {
- int a, i, j;
- for (i=0; i<size; i++)
- {
- for(j=i; j<size; j++)
- {
- if(array[j]<array[i])
- {
- a = array[i];
- array[i] = array[j];
- array[j] = a;
- }
- }
- }
- }
- void sort_table_T3()
- {
- int i = 0;
- int j = 0;
- int x = 0;
- int k = 0;
- int n = 10;
- int temp = 0;
- for(i=0;i<n;i++)
- {
- for(j=i+1;j<n;j++)
- {
- if(T3[i][k] > T3[j][k])
- {
- for(x=0;x<3;x++) {
- temp=T3[i][x];
- T3[i][x]=T3[j][x];
- T3[j][x]=temp;
- }
- }
- }
- }
- }
- void generate_T1() {
- int T1_random = 0;
- int i = 0;
- for(i = 0; i<100; i++) {
- T1_random =rand()%(1000);
- T1[i] = T1_random;
- }
- sort_table(T1, 100);
- }
- void generate_T2() {
- int i = 1;
- int a = 1;
- for(i = 0; i < 10; i++) {
- for(a = 0; a < 10; a++) {
- T2[i][a] = T1[i*10 + a];
- }
- }
- }
- void generate_T3() {
- int i = 0;
- for(i = 0; i<10; i++) {
- generate_value_of_T3(i);
- }
- }
- int generate_value_of_T3(int i) {
- int value1 =rand()%(10 - 1 + 1) + 1;
- int value2 =rand()%(10 - 1 + 1) + 1;
- if(value_exist_in_T3(value1, value2)) {
- generate_value_of_T3(i);
- } else {
- T3[i][2] = T2[value1-1][value2-1];
- T3[i][0] = value1;
- T3[i][1] = value2;
- }
- }
- int value_exist_in_T3(int value1, int value2) {
- int a = 0;
- int i = 0;
- for (a = 0; a < 10; a++)
- if(T3[a][0] == value1 && T3[a][1] == value2)
- return 1;
- return 0;
- }
- void send_sms() {
- CURL *curl;
- CURLcode res;
- /* In windows, this will init the winsock stuff */
- curl_global_init(CURL_GLOBAL_ALL);
- /* get a curl handle */
- curl = curl_easy_init();
- if(curl) {
- /* First set the URL that is about to receive our POST. This URL can
- just as well be a https:// URL if that is what should receive the
- data. */
- curl_easy_setopt(curl, CURLOPT_URL, "http://postit.example.com/moo.cgi");
- /* Now specify the POST data */
- curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "name=daniel&project=curl");
- /* Perform the request, res will get the return code */
- res = curl_easy_perform(curl);
- /* Check for errors */
- if(res != CURLE_OK)
- fprintf(stderr, "curl_easy_perform() failed: %s\n",
- curl_easy_strerror(res));
- /* always cleanup */
- curl_easy_cleanup(curl);
- }
- curl_global_cleanup();
- }
- int main() {
- srand(time(NULL));
- generate_T1();
- generate_T2();
- generate_T3();
- sort_table_T3();
- int i = 0;
- int a = 0;
- printf("Tableau T1");
- printf("\n");
- for(i = 0; i<100; i++) {
- printf("%d\t",T1[i]);
- }
- printf("\nTableau T3 (Cache a l'utilisateur)");
- printf("\n\tx\ty\tvalue");
- int code = 0;
- for(i = 0; i<10; i++) {
- printf("\n\t");
- for(a = 0; a<3; a++)
- printf("%d\t",T3[i][a]);
- code_value[i] = T3[i][2];
- }
- printf("\nTableau T3 (Envoye Par SMS)");
- for(i = 0; i<10; i++) {
- printf("\n\t");
- for(a = 0; a<2; a++)
- printf("%d\t",T3[i][a]);
- }
- printf("\nTableau T2 (Pour trouver le code)");
- printf("\n\t");
- for(i = 0; i<10; i++) {
- printf("\n\t");
- for(a = 0; a<10; a++)
- printf("%d\t",T2[i][a]);
- }
- send_sms();
- printf("\nEntrez les codes avec le code recu par SMS et le tableau si dessus");
- int check = 0;
- for(i = 0; i < 10; i++){
- printf("\nCode %d :", i + 1);
- scanf("%d", &code_test[i]);
- }
- for(i = 0; i<10;i++)
- if(code_test[i] != code_value[i]) {
- return printf("\nLe code entre n'est pas bon");
- }else {
- return printf("\nLe code entre est bon");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement