‏إظهار الرسائل ذات التسميات برمجة. إظهار كافة الرسائل

Algorithme TP-03

Algorithme TP-03



في هذا الموضوع سأقدم لكم ثالث الأعمال التطبيقية في مادة الخوارزميات لتخصص الرياضيات والإعلام الآلي في المركز الجامعي تمنغست .
العمل التطبيقي كان حول صنع تطبيق يقوم بإدخال معلومات مجموعة من الاشخاص وإظهار الاشخاص الذين لديهم نفس الرتبة مع عددهم .
وذالك بإستخدام لغة البرمجة سي / c .


وفي ما يلي الكود الذي يقوم بهذه العملية كل ما عليك هو نسخه في البرامج الذي تستعمله .


#include<stdio.h>
#include<string.h>
#include<stdlib.h>

struct player
        {
       char name[15];
       char as[15];
       int code;
       int grad;
    };

int n;
int i,s1,s2,s3,s4;
float ps1,ps2,ps3,ps4;

void read_calcule_show(void)
{
int t1[n],t2[n];
int t3[n],t4[n];
struct player t[n];
int m,i,s1,s2,s3,s4;
float ps1,ps2,ps3,ps4;
s1=0,s2=0,s3=0,s4=0;
for(i=1;i<=n;i++)
{
printf(" Enter the name : ");
scanf("%s",&t[i].name[15]);
t4[i]=t[i].name[15];
    printf(" The insurance (yes/no) : ");
scanf("%s",&t[i].as[15]);
t3[i]=t[i].as[15];
    printf(" Enter le code :");
scanf("%d",&t[i].code);
t1[i]=t[i].code;
    printf(" Enter le grade : G");
scanf("%d",&t[i].grad);
t2[i]=t[i].grad;
printf("\n");


if(t[i].grad==1)
{
s1=s1+1;
}
else
{
s1=s1;
}
    if(t[i].grad==2)
{
s2=s2+1;
}
else
{
s2=s2;
}
    if(t[i].grad==3)
{
s3=s3+1;
}
else
{
s3=s3;
}
    if(t[i].grad==4)
{
s4=s4+1;
}
else
{
s4=s4;
}
}


ps1=(100*s1)/n;
ps2=(100*s2)/n;
ps3=(100*s3)/n;
ps4=(100*s4)/n;


printf("\n\n");
    printf(" Enter the NBR of Grad =  ");
scanf("%d",&m);

printf("\n --------------< INFORMATIONS OF THE WORKERS : >----------- \n\n\n");

for(i=1;i<=n;i++)
{
if(t[i].grad==m)
{
    printf(" ******* worker %d ******* \n\n",i);
    printf("%s \n",t[i].name);
printf(" worker name : %s \n",t[i].as);
printf(" worker code : %d \n",t[i].code);
printf(" worker grade : G%d  \n",t[i].grad);
printf("\n\n");
}
}
if(m==1)
{
    printf("\n --------------< NBR OF GRADS : >------------------------- \n\n\n");
printf(" Nbr of workers with G1 grad : %d \n\n",s1);
printf("\n --------------< THE PROPORTION OF GRADS : >--------------- \n\n\n");
printf(" G1 grad :    %.2f    100/100 \n",ps1);
printf("\n\n");
}
if(m==2)
{
    printf("\n --------------< NBR OF GRADS : >------------------------- \n\n\n");
printf(" Nbr of workers with G2 grad : %d \n\n",s2);
printf("\n --------------< THE PROPORTION OF GRADS : >--------------- \n\n\n");
printf(" G2 grad :    %.2f    100/100 \n",ps2);
printf("\n\n");
}
if(m==3)
{
    printf("\n --------------< NBR OF GRADS : >------------------------- \n\n\n");
printf(" Nbr of workers with G3 grad : %d \n\n",s3);
printf("\n --------------< THE PROPORTION OF GRADS : >--------------- \n\n\n");
printf(" G3 grad :    %.2f    100/100 \n",ps3);
printf("\n\n");
}
if(m==4)
{
    printf("\n --------------< NBR OF GRADS : >------------------------- \n\n\n");
printf(" Nbr of workers with G4 grad : %d \n\n",s4);
printf("\n --------------< THE PROPORTION OF GRADS : >--------------- \n\n\n");
printf(" G4 grad :    %.2f    100/100 \n",ps4);
printf("\n\n");
}
}


int main(void)
{
printf("\n                   ----<  TP 03 EN ALGORITHME  >---- \n\n");
printf("                       ----<   CREATED BY  >---- \n\n");
    printf("            ----<  ZOUBIR LANSARI   >---- \n\n");
    printf("                       ----<  2016 / 2017  >----    \n\n");

    printf(" Enter number of workers N =  ");
scanf("%d",&n);
if (n<4 || n>120)
{
printf("\a\a\a\a\a\a");
printf("\n\n\n");
printf(" the value of N is : \n\n\n\n");
printf("  ######################################################## \n");
printf("  #                                                      # \n");
printf("  #  #  #     #      ##   ##     #       #   ##### ####  # \n");
printf("  #  #  #    #  ##   ###  ##    #  ##  ###       # #  #  # \n");
printf("  #  ####   #        ## # ##   #         #   ##### #  #  # \n");
printf("  #     #    #  ##   ##  ###    #  ##    #   #     #  #  # \n");
printf("  #     #     #      ##   ##     #     ##### ##### ####  # \n");
printf("  #                                                      # \n");
printf("  ######################################################## \n\n\n\n");

}
else
    {
printf("\n\n\n");
printf("  ######################################################## \n");
    printf("  #                                                      # \n");
    printf("  #    the name contain 15 characters                    # \n");
    printf("  #    if the worker have an insurance enter yes or no   # \n");
printf("  #    the code is an int NBR         Exp : 100001       # \n");
printf("  #    the grade is one of this NBRs (1 , 2 , 3 , 4 )    # \n");
    printf("  #                                                      # \n");
printf("  ######################################################## \n\n\n\n"); 
printf("\n");


read_calcule_show();

}
}

أرجوا أن يكون الموضوع قد نال إعجابكم.

TP en JAVA





في هذا الموضوع سأقدم لكم ثاني الأعمال التطبيقية في لغة الجافا  لتخصص الإعلام الآلي في جامعة الغواط عمار ثليجي .



وفي ما يلي الحلول لكل التمارين ... اذا كان هناك أي خطا في الاكواد يرجي ذكره ي التعليقات ☺ .


EX01 :



import java.util.Scanner;

public class ex1 {

       public static void main (String[]args) {

       Scanner in = new Scanner(System.in);
       System.out.println ("enter val de a : ");
       int a = in.nextInt();
       System.out.println ("enter val de b : ");
       int b = in.nextInt();
       System.out.println ("enter val de c : ");
       int c = in.nextInt();
       b=a;
       c=b;
       a=c;
       System.out.println ("val de a : " + a );
       System.out.println ("val de b : " + b );
       System.out.println ("val de c : " + c );
}
}

EX02 :


import java.util.Scanner;
public class ex2 {
       public static void main (String[]args) {
       float q;
       int r;
       Scanner in = new Scanner(System.in);
       System.out.println ("entre le nebre1 : ");
       int a = in.nextInt();
       System.out.println ("entre le nebre2 : ");
       int b = in.nextInt();
       q=a/b;
       r=a%b;
       System.out.println ("Quotiet : " + q );
       System.out.println ("rest de dev : " + r );

}
}

EX03 :


import static java.lang.Math.sqrt;
import java.util.Scanner;
public class ex3 {
       public static void main (String[]args) {
       double r_s,r_p;

       Scanner in = new Scanner(System.in);

       System.out.println ("entre le type de branchees 1 ou 2: ");
       int type = in.nextInt();


       if(type==1)
       {

       System.out.println ("entre R1 : ");
       double R1 = in.nextDouble();
       System.out.println ("entre R2 : ");
       double R2 = in.nextDouble();
       System.out.println ("entre R3 : ");
       double R3 = in.nextDouble();

       r_s=R1+R2+R3;
       System.out.println ("result : " + r_s);
       }
       else
       {
       if(type==2)
       {

       System.out.println ("entre R1 : ");
       double R1 = in.nextDouble();
       System.out.println ("entre R2 : ");
       double R2 = in.nextDouble();
       System.out.println ("entre R3 : ");
       double R3 = in.nextDouble();

       r_p=(R1+R2+R3)/((R1*R2)+(R1*R3)+(R2*R3));
       System.out.println ("result : " + r_p);
       }
       }
}
}

EX04 :


import java.util.Scanner;
public class ex44 {


    public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int e,i;
    e=0;
    int tab[]=new int[4];
    for(i=0;i<4;i++)
    {
    System.out.println("entre la valeur de tab:");
    tab[i]=in.nextInt();

    e=e+tab[i];

    }

    System.out.println("result de la some : "+e);

    }
    
}

EX05 :


import java.util.Scanner;
public class ex5 {
       public static void main (String[]args) {
       Scanner in = new Scanner(System.in);
       
       double pttc;
       int pnet,tva;
       System.out.println("entre la valeur de PNET :");
       pnet = in.nextInt();
       System.out.println("entre la valeur de TVA :");
       tva = in.nextInt();

       pttc=pnet + (pnet*tva)/100;
       System.out.println("prix TTc est :"+ pttc);
}
}

EX06 :


import static java.lang.Math.sqrt;
import java.util.Scanner;
public class ex6 {
public static void main (String[]args) {
Scanner in = new Scanner(System.in);

double DIST;
int XA,YA,XB,YB;

double a,b;
       System.out.println("entre XA :");
       XA = in.nextInt();
       System.out.println("entre YA :");
       YA = in.nextInt();
       System.out.println("entre XB :");
       XB = in.nextInt();
       System.out.println("entre YB :");
       YB = in.nextInt();

a=sqrt((XA*XA)+(YA*YA));
b=sqrt((XB*XB)+(YB*YB));
DIST=sqrt((a*a)+(b*b));

       System.out.println("distance :"+ DIST);
}
}


أرجوا أن يكون الموضوع قد نال إعجابكم.