Java
This commit is contained in:
parent
0ee0894cd5
commit
08f8c6f578
@ -9,9 +9,6 @@ int main(int argc, char *argv[]){
|
|||||||
int jour_lettre = 0;
|
int jour_lettre = 0;
|
||||||
printf ("Entrez une date : \n");
|
printf ("Entrez une date : \n");
|
||||||
scanf("%d/%d/%d",&jour,&mois,&annee);
|
scanf("%d/%d/%d",&jour,&mois,&annee);
|
||||||
time.tm_year = annee;
|
|
||||||
time.tm_mon = mois;
|
|
||||||
time.tm_mday = jour;
|
|
||||||
if (time.tm_mday%6+1 == 0){
|
if (time.tm_mday%6+1 == 0){
|
||||||
printf("C'est un Dimanche\n");
|
printf("C'est un Dimanche\n");
|
||||||
}
|
}
|
||||||
|
BIN
APL1.1/vieirae_CM2.tar.gz
Normal file
BIN
APL1.1/vieirae_CM2.tar.gz
Normal file
Binary file not shown.
BIN
APL1.2/SCR1.2/TP11/get_numb
Executable file
BIN
APL1.2/SCR1.2/TP11/get_numb
Executable file
Binary file not shown.
@ -5,35 +5,35 @@
|
|||||||
#include<string.h>
|
#include<string.h>
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
|
int f ,l ,x ,n;
|
||||||
int fird,ent,ents;
|
long int i, offset;
|
||||||
off_t i;
|
if (argc < 3) {
|
||||||
char tst[256];
|
fprintf (stdin,"Usage : %s <file><offset> \n",argv[0]);
|
||||||
size_t n=1,m=1;
|
exit(1);
|
||||||
memset(tst,0,256);
|
}
|
||||||
|
f=open(argv[1],O_RDONLY);
|
||||||
|
if (f==1){
|
||||||
|
perror("Opening file failed !");
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
i = strtol (argv[2],NULL,0);
|
||||||
|
offset = i*sizeof(int);
|
||||||
|
l = lseek(f,offset,SEEK_SET);
|
||||||
|
if (l==-1){
|
||||||
|
perror("lseek fails !");
|
||||||
|
exit(3);
|
||||||
|
}
|
||||||
|
n = read(f,&x,sizeof(int));
|
||||||
|
if(n==-1){
|
||||||
|
perror("reading file fails !");
|
||||||
|
exit(4);
|
||||||
|
}
|
||||||
|
if (n==0){
|
||||||
|
printf("Out of range !\n");
|
||||||
|
}else{
|
||||||
|
printf("The number at offset %d is 0x%08x --> %d \n",i,x,x);
|
||||||
|
}
|
||||||
|
close(f);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
if(argc!=3){
|
|
||||||
printf("erreur : %s <Nom Fichier> <offset>\n",argv[0]);
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
fird=open(argv[1],O_CREAT|O_RDONLY,0600);
|
|
||||||
if(fird==-1){
|
|
||||||
perror("On ne peut pas ouvrir cela en O_WRONLY");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
ent = strtol(argv[2],NULL,10);
|
|
||||||
|
|
||||||
lseek(fird,ent*4,SEEK_SET);
|
|
||||||
i=read(fird,&ents,4);
|
|
||||||
if(i==0){
|
|
||||||
printf("Offset is out of range!\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
printf("The number at offset %d is 0x%08x --> %d\n",ent,ents,ents);
|
|
||||||
|
|
||||||
close(fird);
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
BIN
APL1.2/SCR1.2/TP11/number.dat
Normal file
BIN
APL1.2/SCR1.2/TP11/number.dat
Normal file
Binary file not shown.
0
APL1.2/SCR1.2/TP11/number.dat*
Normal file
0
APL1.2/SCR1.2/TP11/number.dat*
Normal file
0
APL1.2/SCR1.2/TP11/numbers.dat
Normal file
0
APL1.2/SCR1.2/TP11/numbers.dat
Normal file
@ -1,5 +1,8 @@
|
|||||||
5
|
ERWAN
|
||||||
8
|
LA
|
||||||
6
|
S
|
||||||
4
|
A
|
||||||
8
|
L
|
||||||
|
O
|
||||||
|
P
|
||||||
|
E
|
||||||
|
BIN
APL1.2/SCR1.2/TP11/put_numb
Executable file
BIN
APL1.2/SCR1.2/TP11/put_numb
Executable file
Binary file not shown.
@ -5,41 +5,31 @@
|
|||||||
#include<string.h>
|
#include<string.h>
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
|
int f,n;
|
||||||
int fird,ent,ents;
|
unsigned int x;
|
||||||
short int i;
|
unsigned long int i, offset, l;
|
||||||
off_t l;
|
|
||||||
char tst[256];
|
|
||||||
size_t n=1,m=1;
|
|
||||||
memset(tst,0,256);
|
memset(tst,0,256);
|
||||||
|
if(argc<4){
|
||||||
if(argc!=4){
|
|
||||||
printf("erreur : %s <file_name> <32-bit int in Hex> <Offset in Hex>\n",argv[0]);
|
printf("erreur : %s <file_name> <32-bit int in Hex> <Offset in Hex>\n",argv[0]);
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
fird=open(argv[1],O_CREAT|O_WRONLY,0600);
|
|
||||||
if(fird==-1){
|
|
||||||
perror("On ne peut pas ouvrir cela en O_RDONLY");
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
f=open(argv[1],O_WRONLY);
|
||||||
ent = strtol(argv[3],NULL,16);
|
if(f==-1){
|
||||||
|
perror("Opening failed");
|
||||||
l=lseek(fird,ent*4,SEEK_SET);
|
exit(2);
|
||||||
printf("%ld\n",l);
|
}
|
||||||
|
x= (unsigned int)strtol(argv[2],NULL,16);
|
||||||
|
i= (unsigned int)strtol(argv[3],NULL,16);
|
||||||
|
offset = i*sizeof(int);
|
||||||
|
l=lseek(f,0,SEEK_END);
|
||||||
|
if (offset > l) offset =l;
|
||||||
|
l=lseek(f,offset,SEEK_SET);
|
||||||
if(l==-1){
|
if(l==-1){
|
||||||
perror("erreur dans lseek");
|
perror("erreur dans lseek");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ents = strtol(argv[2],NULL,16);
|
ents = strtol(argv[2],NULL,16);
|
||||||
|
write(f,&x,sizeof(int));
|
||||||
write(fird,&ents,4);
|
close(f);
|
||||||
|
|
||||||
close(fird);
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
BIN
APL1.2/SCR1.2/TP11/store_nb_rep
Executable file
BIN
APL1.2/SCR1.2/TP11/store_nb_rep
Executable file
Binary file not shown.
32
APL1.2/SCR1.2/TP11/store_nb_rep.c
Normal file
32
APL1.2/SCR1.2/TP11/store_nb_rep.c
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#include<stdio.h>
|
||||||
|
#include<stdlib.h>
|
||||||
|
#include<fcntl.h>
|
||||||
|
#define BUFSIZE 256
|
||||||
|
|
||||||
|
int main(int argc, char * argv[]){
|
||||||
|
int r,x,f,y,n;
|
||||||
|
char buf[BUFSIZE];
|
||||||
|
if(argc<2){
|
||||||
|
fprintf(stdin,"Usage: %s <file>\n",argv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
f=open(argv[1],O_WRONLY|O_CREAT|O_TRUNC,0600);
|
||||||
|
if(f==-1){
|
||||||
|
perror("Opening file failed !");
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
write(1,"Numb --> ",9);
|
||||||
|
memset(buf,0,BUFSIZE);
|
||||||
|
while(n=read(0,buf,BUFSIZE)){
|
||||||
|
x = (int)strtol(buf,NULL,0);
|
||||||
|
r=write(f,buf,sizeof(int));
|
||||||
|
if(r==-1){
|
||||||
|
perror("writing failed");
|
||||||
|
exit(3);
|
||||||
|
}
|
||||||
|
write(1,"Numb --> ",9);
|
||||||
|
memset (buf,0,BUFSIZE);
|
||||||
|
}
|
||||||
|
close(f);
|
||||||
|
exit(0);
|
||||||
|
}
|
237
APL1.2/SCR1.2/TP12/de commandes avec sed :
Normal file
237
APL1.2/SCR1.2/TP12/de commandes avec sed :
Normal file
@ -0,0 +1,237 @@
|
|||||||
|
SED(1) User Commands SED(1)
|
||||||
|
|
||||||
|
NNAAMMEE
|
||||||
|
sed - stream editor for filtering and transforming text
|
||||||
|
|
||||||
|
SSYYNNOOPPSSIISS
|
||||||
|
sseedd [_O_P_T_I_O_N]... _{_s_c_r_i_p_t_-_o_n_l_y_-_i_f_-_n_o_-_o_t_h_e_r_-_s_c_r_i_p_t_} [_i_n_p_u_t_-_f_i_l_e]...
|
||||||
|
|
||||||
|
DDEESSCCRRIIPPTTIIOONN
|
||||||
|
_S_e_d is a stream editor. A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline). While in some ways sim‐
|
||||||
|
ilar to an editor which permits scripted edits (such as _e_d), _s_e_d works by making only one pass over the input(s), and is consequently more efficient. But it is
|
||||||
|
_s_e_d's ability to filter text in a pipeline which particularly distinguishes it from other types of editors.
|
||||||
|
|
||||||
|
--nn, ----qquuiieett, ----ssiilleenntt
|
||||||
|
|
||||||
|
suppress automatic printing of pattern space
|
||||||
|
|
||||||
|
----ddeebbuugg
|
||||||
|
|
||||||
|
annotate program execution
|
||||||
|
|
||||||
|
--ee script, ----eexxpprreessssiioonn=_s_c_r_i_p_t
|
||||||
|
|
||||||
|
add the script to the commands to be executed
|
||||||
|
|
||||||
|
--ff script-file, ----ffiillee=_s_c_r_i_p_t_-_f_i_l_e
|
||||||
|
|
||||||
|
add the contents of script-file to the commands to be executed
|
||||||
|
|
||||||
|
----ffoollllooww--ssyymmlliinnkkss
|
||||||
|
|
||||||
|
follow symlinks when processing in place
|
||||||
|
|
||||||
|
--ii[[SSUUFFFFIIXX]], ----iinn--ppllaaccee[=_S_U_F_F_I_X]
|
||||||
|
|
||||||
|
edit files in place (makes backup if SUFFIX supplied)
|
||||||
|
|
||||||
|
--ll N, ----lliinnee--lleennggtthh=_N
|
||||||
|
|
||||||
|
specify the desired line-wrap length for the `l' command
|
||||||
|
|
||||||
|
----ppoossiixx
|
||||||
|
|
||||||
|
disable all GNU extensions.
|
||||||
|
|
||||||
|
--EE, --rr, ----rreeggeexxpp--eexxtteennddeedd
|
||||||
|
|
||||||
|
use extended regular expressions in the script (for portability use POSIX --EE).
|
||||||
|
|
||||||
|
--ss, ----sseeppaarraattee
|
||||||
|
|
||||||
|
consider files as separate rather than as a single, continuous long stream.
|
||||||
|
|
||||||
|
----ssaannddbbooxx
|
||||||
|
|
||||||
|
operate in sandbox mode (disable e/r/w commands).
|
||||||
|
|
||||||
|
--uu, ----uunnbbuuffffeerreedd
|
||||||
|
|
||||||
|
load minimal amounts of data from the input files and flush the output buffers more often
|
||||||
|
|
||||||
|
--zz, ----nnuullll--ddaattaa
|
||||||
|
|
||||||
|
separate lines by NUL characters
|
||||||
|
|
||||||
|
----hheellpp
|
||||||
|
display this help and exit
|
||||||
|
|
||||||
|
----vveerrssiioonn
|
||||||
|
output version information and exit
|
||||||
|
|
||||||
|
If no --ee, ----eexxpprreessssiioonn, --ff, or ----ffiillee option is given, then the first non-option argument is taken as the sed script to interpret. All remaining arguments are names
|
||||||
|
of input files; if no input files are specified, then the standard input is read.
|
||||||
|
|
||||||
|
GNU sed home page: <https://www.gnu.org/software/sed/>. General help using GNU software: <https://www.gnu.org/gethelp/>. E-mail bug reports to: <bug-sed@gnu.org>.
|
||||||
|
|
||||||
|
CCOOMMMMAANNDD SSYYNNOOPPSSIISS
|
||||||
|
This is just a brief synopsis of _s_e_d commands to serve as a reminder to those who already know _s_e_d; other documentation (such as the texinfo document) must be con‐
|
||||||
|
sulted for fuller descriptions.
|
||||||
|
|
||||||
|
ZZeerroo--aaddddrreessss ````ccoommmmaannddss''''
|
||||||
|
: _l_a_b_e_l
|
||||||
|
Label for bb and tt commands.
|
||||||
|
|
||||||
|
#_c_o_m_m_e_n_t
|
||||||
|
The comment extends until the next newline (or the end of a --ee script fragment).
|
||||||
|
|
||||||
|
} The closing bracket of a { } block.
|
||||||
|
|
||||||
|
ZZeerroo-- oorr OOnnee-- aaddddrreessss ccoommmmaannddss
|
||||||
|
= Print the current line number.
|
||||||
|
|
||||||
|
a \
|
||||||
|
|
||||||
|
_t_e_x_t Append _t_e_x_t, which has each embedded newline preceded by a backslash.
|
||||||
|
|
||||||
|
i \
|
||||||
|
|
||||||
|
_t_e_x_t Insert _t_e_x_t, which has each embedded newline preceded by a backslash.
|
||||||
|
|
||||||
|
q [_e_x_i_t_-_c_o_d_e]
|
||||||
|
Immediately quit the _s_e_d script without processing any more input, except that if auto-print is not disabled the current pattern space will be printed. The
|
||||||
|
exit code argument is a GNU extension.
|
||||||
|
|
||||||
|
Q [_e_x_i_t_-_c_o_d_e]
|
||||||
|
Immediately quit the _s_e_d script without processing any more input. This is a GNU extension.
|
||||||
|
|
||||||
|
r _f_i_l_e_n_a_m_e
|
||||||
|
Append text read from _f_i_l_e_n_a_m_e.
|
||||||
|
|
||||||
|
R _f_i_l_e_n_a_m_e
|
||||||
|
Append a line read from _f_i_l_e_n_a_m_e. Each invocation of the command reads a line from the file. This is a GNU extension.
|
||||||
|
|
||||||
|
CCoommmmaannddss wwhhiicchh aacccceepptt aaddddrreessss rraannggeess
|
||||||
|
{ Begin a block of commands (end with a }).
|
||||||
|
|
||||||
|
b _l_a_b_e_l
|
||||||
|
Branch to _l_a_b_e_l; if _l_a_b_e_l is omitted, branch to end of script.
|
||||||
|
|
||||||
|
c \
|
||||||
|
|
||||||
|
_t_e_x_t Replace the selected lines with _t_e_x_t, which has each embedded newline preceded by a backslash.
|
||||||
|
|
||||||
|
d Delete pattern space. Start next cycle.
|
||||||
|
|
||||||
|
D If pattern space contains no newline, start a normal new cycle as if the d command was issued. Otherwise, delete text in the pattern space up to the first
|
||||||
|
newline, and restart cycle with the resultant pattern space, without reading a new line of input.
|
||||||
|
|
||||||
|
h H Copy/append pattern space to hold space.
|
||||||
|
|
||||||
|
g G Copy/append hold space to pattern space.
|
||||||
|
|
||||||
|
l List out the current line in a ``visually unambiguous'' form.
|
||||||
|
|
||||||
|
l _w_i_d_t_h
|
||||||
|
List out the current line in a ``visually unambiguous'' form, breaking it at _w_i_d_t_h characters. This is a GNU extension.
|
||||||
|
|
||||||
|
n N Read/append the next line of input into the pattern space.
|
||||||
|
|
||||||
|
p Print the current pattern space.
|
||||||
|
|
||||||
|
P Print up to the first embedded newline of the current pattern space.
|
||||||
|
|
||||||
|
s/_r_e_g_e_x_p/_r_e_p_l_a_c_e_m_e_n_t/
|
||||||
|
Attempt to match _r_e_g_e_x_p against the pattern space. If successful, replace that portion matched with _r_e_p_l_a_c_e_m_e_n_t. The _r_e_p_l_a_c_e_m_e_n_t may contain the special
|
||||||
|
character && to refer to that portion of the pattern space which matched, and the special escapes \1 through \9 to refer to the corresponding matching sub-ex‐
|
||||||
|
pressions in the _r_e_g_e_x_p.
|
||||||
|
|
||||||
|
t _l_a_b_e_l
|
||||||
|
If a s/// has done a successful substitution since the last input line was read and since the last t or T command, then branch to _l_a_b_e_l; if _l_a_b_e_l is omitted,
|
||||||
|
branch to end of script.
|
||||||
|
|
||||||
|
T _l_a_b_e_l
|
||||||
|
If no s/// has done a successful substitution since the last input line was read and since the last t or T command, then branch to _l_a_b_e_l; if _l_a_b_e_l is omitted,
|
||||||
|
branch to end of script. This is a GNU extension.
|
||||||
|
|
||||||
|
w _f_i_l_e_n_a_m_e
|
||||||
|
Write the current pattern space to _f_i_l_e_n_a_m_e.
|
||||||
|
|
||||||
|
W _f_i_l_e_n_a_m_e
|
||||||
|
Write the first line of the current pattern space to _f_i_l_e_n_a_m_e. This is a GNU extension.
|
||||||
|
|
||||||
|
x Exchange the contents of the hold and pattern spaces.
|
||||||
|
|
||||||
|
y/_s_o_u_r_c_e/_d_e_s_t/
|
||||||
|
Transliterate the characters in the pattern space which appear in _s_o_u_r_c_e to the corresponding character in _d_e_s_t.
|
||||||
|
|
||||||
|
AAddddrreesssseess
|
||||||
|
_S_e_d commands can be given with no addresses, in which case the command will be executed for all input lines; with one address, in which case the command will only be
|
||||||
|
executed for input lines which match that address; or with two addresses, in which case the command will be executed for all input lines which match the inclusive
|
||||||
|
range of lines starting from the first address and continuing to the second address. Three things to note about address ranges: the syntax is _a_d_d_r_1,_a_d_d_r_2 (i.e., the
|
||||||
|
addresses are separated by a comma); the line which _a_d_d_r_1 matched will always be accepted, even if _a_d_d_r_2 selects an earlier line; and if _a_d_d_r_2 is a _r_e_g_e_x_p, it will
|
||||||
|
not be tested against the line that _a_d_d_r_1 matched.
|
||||||
|
|
||||||
|
After the address (or address-range), and before the command, a !! may be inserted, which specifies that the command shall only be executed if the address (or ad‐
|
||||||
|
dress-range) does nnoott match.
|
||||||
|
|
||||||
|
The following address types are supported:
|
||||||
|
|
||||||
|
_n_u_m_b_e_r Match only the specified line _n_u_m_b_e_r (which increments cumulatively across files, unless the --ss option is specified on the command line).
|
||||||
|
|
||||||
|
_f_i_r_s_t~_s_t_e_p
|
||||||
|
Match every _s_t_e_p'th line starting with line _f_i_r_s_t. For example, ``sed -n 1~2p'' will print all the odd-numbered lines in the input stream, and the address
|
||||||
|
2~5 will match every fifth line, starting with the second. _f_i_r_s_t can be zero; in this case, _s_e_d operates as if it were equal to _s_t_e_p. (This is an exten‐
|
||||||
|
sion.)
|
||||||
|
|
||||||
|
$ Match the last line.
|
||||||
|
|
||||||
|
/_r_e_g_e_x_p/
|
||||||
|
Match lines matching the regular expression _r_e_g_e_x_p. Matching is performed on the current pattern space, which can be modified with commands such as ``s///''.
|
||||||
|
|
||||||
|
\cc_r_e_g_e_x_pcc
|
||||||
|
Match lines matching the regular expression _r_e_g_e_x_p. The cc may be any character.
|
||||||
|
|
||||||
|
GNU _s_e_d also supports some special 2-address forms:
|
||||||
|
|
||||||
|
0,_a_d_d_r_2
|
||||||
|
Start out in "matched first address" state, until _a_d_d_r_2 is found. This is similar to 1,_a_d_d_r_2, except that if _a_d_d_r_2 matches the very first line of input the
|
||||||
|
0,_a_d_d_r_2 form will be at the end of its range, whereas the 1,_a_d_d_r_2 form will still be at the beginning of its range. This works only when _a_d_d_r_2 is a regular
|
||||||
|
expression.
|
||||||
|
|
||||||
|
_a_d_d_r_1,+_N
|
||||||
|
Will match _a_d_d_r_1 and the _N lines following _a_d_d_r_1.
|
||||||
|
|
||||||
|
_a_d_d_r_1,~_N
|
||||||
|
Will match _a_d_d_r_1 and the lines following _a_d_d_r_1 until the next line whose input line number is a multiple of _N.
|
||||||
|
|
||||||
|
RREEGGUULLAARR EEXXPPRREESSSSIIOONNSS
|
||||||
|
POSIX.2 BREs _s_h_o_u_l_d be supported, but they aren't completely because of performance problems. The \\nn sequence in a regular expression matches the newline character,
|
||||||
|
and similarly for \\aa, \\tt, and other sequences. The _-_E option switches to using extended regular expressions instead; it has been supported for years by GNU sed, and
|
||||||
|
is now included in POSIX.
|
||||||
|
|
||||||
|
BBUUGGSS
|
||||||
|
E-mail bug reports to bbuugg--sseedd@@ggnnuu..oorrgg. Also, please include the output of ``sed --version'' in the body of your report if at all possible.
|
||||||
|
|
||||||
|
AAUUTTHHOORR
|
||||||
|
Written by Jay Fenlason, Tom Lord, Ken Pizzini, Paolo Bonzini, Jim Meyering, and Assaf Gordon.
|
||||||
|
|
||||||
|
This sed program was built with SELinux support. SELinux is enabled on this system.
|
||||||
|
|
||||||
|
GNU sed home page: <https://www.gnu.org/software/sed/>. General help using GNU software: <https://www.gnu.org/gethelp/>. E-mail bug reports to: <bug-sed@gnu.org>.
|
||||||
|
|
||||||
|
CCOOPPYYRRIIGGHHTT
|
||||||
|
Copyright © 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
|
||||||
|
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
|
||||||
|
|
||||||
|
SSEEEE AALLSSOO
|
||||||
|
aawwkk(1), eedd(1), ggrreepp(1), ttrr(1), ppeerrllrree(1), sed.info, any of various books on _s_e_d, the _s_e_d FAQ (http://sed.sf.net/grabbag/tutorials/sedfaq.txt),
|
||||||
|
http://sed.sf.net/grabbag/.
|
||||||
|
|
||||||
|
The full documentation for sseedd is maintained as a Texinfo manual. If the iinnffoo and sseedd programs are properly installed at your site, the command
|
||||||
|
|
||||||
|
iinnffoo sseedd
|
||||||
|
|
||||||
|
should give you access to the complete manual.
|
||||||
|
|
||||||
|
sed 4.8 January 2020 SED(1)
|
BIN
APL1.2/SCR1.2/TP12/regexp
Executable file
BIN
APL1.2/SCR1.2/TP12/regexp
Executable file
Binary file not shown.
35
APL1.2/SCR1.2/TP12/regexp.c
Normal file
35
APL1.2/SCR1.2/TP12/regexp.c
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <regex.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char * argv [])
|
||||||
|
{
|
||||||
|
regex_t regex;
|
||||||
|
int retour;
|
||||||
|
char message [128];
|
||||||
|
|
||||||
|
if (argc != 3) {
|
||||||
|
fprintf (stderr, "syntaxe : %s expression chaine\n",
|
||||||
|
argv [0]);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((retour = regcomp (& regex, argv [1], REG_NOSUB)) != 0) {
|
||||||
|
regerror (retour, & regex, message, 128);
|
||||||
|
fprintf (stderr, "Erreur : %s\n", message);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (regexec (& regex, argv [2], 0, NULL, 0) == 0)
|
||||||
|
fprintf (stdout, "Correspondance !\n");
|
||||||
|
else
|
||||||
|
fprintf (stdout, "Pas de correspondance.\n");
|
||||||
|
|
||||||
|
regfree (& regex);
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
21
APL1.2/SCR1.2/TP12/td7.txt
Normal file
21
APL1.2/SCR1.2/TP12/td7.txt
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
Expressions régulières :
|
||||||
|
|
||||||
|
. -> exactement un caractère
|
||||||
|
[] -> co ̈ıncide avec n’importe quel caractère -exactement un caractère- inclus dans les [ ].
|
||||||
|
^ et $ début et fin de lignes
|
||||||
|
exemple : ’^..[[:digit:]]’ toutes les lignes qui commencent par deux caractère quelconques puis un chiffre.
|
||||||
|
\ -> protège un caractère, exmple \. = .
|
||||||
|
’[^[:upper:]].$’ -> toutes les lignes qui se terminent par un caractère quelconques sauf précédée par une majuscule.
|
||||||
|
|
||||||
|
Exercice 2 :
|
||||||
|
’T?ST?AR’ -> ? = SAR , TSAR, STAR, TSTAR
|
||||||
|
’(back)?(slash)?’ -> backslash, back, slash, ' '
|
||||||
|
’^[[:space:]]*$’ -> 0 ou un espace avant un caractère.
|
||||||
|
’^.?..$’ , ’^..?.$’ , ’^...?$’ , ’^.{2,3}$ -> 2 ou 3 caractère sur la ligne.
|
||||||
|
’(ding-deng-dong)+’ -> une ou plusieurs fois (ding-deng-dong)
|
||||||
|
’^[[:space:]]+$’ -> 1 ou plusieurs fois espace
|
||||||
|
’[$][[:digit:]]?$’ -> fini par "$" ou par "$" et un chiffre.
|
||||||
|
|
||||||
|
Exercice 3 :
|
||||||
|
1) c'est un .config ou .cfg ’[.](config|cfg)’
|
||||||
|
2) ’[$]([[:digit:]]|$)’ -> se termine par un $ sigit ou un $.
|
3
APL1.2/SCR1.2/TP12/tp12.txt
Normal file
3
APL1.2/SCR1.2/TP12/tp12.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
grep -E : version étendue.
|
||||||
|
grep -i : ignorer les cas.
|
||||||
|
grep -v : inverser le sens, selectionner les lignes qui ne matchent pas.
|
7
APL2.1/TP1/Arguments.java
Normal file
7
APL2.1/TP1/Arguments.java
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
public class Arguments {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
for(int i = 0; i < args.length; i++) {
|
||||||
|
System.out.println("Salut " + args[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
20
APL2.1/TP1/Demarrage.java
Normal file
20
APL2.1/TP1/Demarrage.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
public class Demarrage {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
byte premier = 123;
|
||||||
|
short deuxieme = 124;
|
||||||
|
int troisieme = -125;
|
||||||
|
long quatre = 126L;
|
||||||
|
boolean cinq = true;
|
||||||
|
char six = 'o';
|
||||||
|
float sept = 13.5f;
|
||||||
|
double huit = 50.0d;
|
||||||
|
System.out.println(premier);
|
||||||
|
System.out.println(deuxieme);
|
||||||
|
System.out.println(troisieme);
|
||||||
|
System.out.println(quatre);
|
||||||
|
System.out.println(cinq);
|
||||||
|
System.out.println(six);
|
||||||
|
System.out.println(sept);
|
||||||
|
System.out.println(huit);
|
||||||
|
}
|
||||||
|
}
|
9
APL2.1/TP1/Somme.java
Normal file
9
APL2.1/TP1/Somme.java
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
public class Somme {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
int total = 0;
|
||||||
|
for(int i = 0; i < args.length; i++) {
|
||||||
|
total = total + Integer.parseInt(args[i]);;
|
||||||
|
}
|
||||||
|
System.out.print("La somme totale est : " + total);
|
||||||
|
}
|
||||||
|
}
|
14
APL2.1/TP1/Tri.java
Normal file
14
APL2.1/TP1/Tri.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import java.util.Arrays;
|
||||||
|
public class Tri {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
int[] total = null;
|
||||||
|
total = new int[args.length];
|
||||||
|
for(int i = 0; i < args.length; i++) {
|
||||||
|
total[i] = Integer.parseInt(args[i]);
|
||||||
|
}
|
||||||
|
Arrays.sort(total);
|
||||||
|
for(int i = 0; i < args.length; i++) {
|
||||||
|
System.out.println(total[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
22
APL2.1/TP1/grille.java
Normal file
22
APL2.1/TP1/grille.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
public class grille {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
for(int j = 0; j < Integer.parseInt(args[0]); j++) {
|
||||||
|
System.out.print("+");
|
||||||
|
for(int i = 0; i < Integer.parseInt(args[0]); i++) {
|
||||||
|
System.out.print("-+");
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.print("\n|");
|
||||||
|
for(int i = 0; i < Integer.parseInt(args[0]); i++) {
|
||||||
|
System.out.print(" |");
|
||||||
|
}
|
||||||
|
System.out.print("\n");
|
||||||
|
}
|
||||||
|
System.out.print("+");
|
||||||
|
for(int i = 0; i < Integer.parseInt(args[0]); i++) {
|
||||||
|
System.out.print("-+");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
BIN
APL2.1/TP2/Boutons.class
Normal file
BIN
APL2.1/TP2/Boutons.class
Normal file
Binary file not shown.
21
APL2.1/TP2/Boutons.java
Normal file
21
APL2.1/TP2/Boutons.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class Boutons {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
JFrame fenetre = new JFrame();
|
||||||
|
fenetre.setSize(500,300);
|
||||||
|
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
JButton bouton1 = new JButton("Bouton1");
|
||||||
|
fenetre.add(bouton1, BorderLayout.WEST);
|
||||||
|
JButton bouton2 = new JButton("Bouton2");
|
||||||
|
fenetre.add(bouton2, BorderLayout.NORTH);
|
||||||
|
JButton bouton3 = new JButton("Bouton3");
|
||||||
|
fenetre.add(bouton3, BorderLayout.EAST);
|
||||||
|
JButton bouton4 = new JButton("Bouton4");
|
||||||
|
fenetre.add(bouton4, BorderLayout.SOUTH);
|
||||||
|
JButton bouton5 = new JButton("Bouton5");
|
||||||
|
fenetre.add(bouton5, BorderLayout.CENTER);
|
||||||
|
fenetre.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
BIN
APL2.1/TP2/Saisie.class
Normal file
BIN
APL2.1/TP2/Saisie.class
Normal file
Binary file not shown.
21
APL2.1/TP2/Saisie.java
Normal file
21
APL2.1/TP2/Saisie.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class Saisie {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
JFrame fenetre = new JFrame();
|
||||||
|
fenetre.setSize(1920,300);
|
||||||
|
fenetre.setLocation(0,0);
|
||||||
|
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
JTextArea Texte = new JTextArea();
|
||||||
|
JTextField Zone = new JTextField();
|
||||||
|
Texte.setBackground(new Color(0,0,0));
|
||||||
|
Zone.setBackground(new Color(50,50,50));
|
||||||
|
Texte.setForeground(new Color(0,255,0));
|
||||||
|
Zone.setForeground(new Color(0,255,0));
|
||||||
|
fenetre.add(Texte, BorderLayout.CENTER);
|
||||||
|
fenetre.add(Zone, BorderLayout.SOUTH);
|
||||||
|
fenetre.setVisible(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
BIN
APL2.1/TP2/Sirocco.class
Normal file
BIN
APL2.1/TP2/Sirocco.class
Normal file
Binary file not shown.
14
APL2.1/TP2/Sirocco.java
Normal file
14
APL2.1/TP2/Sirocco.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class Sirocco {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
JFrame fenetre = new JFrame();
|
||||||
|
fenetre.setSize(500,300);
|
||||||
|
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
JLabel etiquette = new JLabel("Sirocco");
|
||||||
|
etiquette.setHorizontalAlignment(JLabel.LEFT);
|
||||||
|
fenetre.add(etiquette, BorderLayout.NORTH);
|
||||||
|
fenetre.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user