First commit
This commit is contained in:
28
IUT/Info1/TD/Exercices/10.9/.vscode/tasks.json
vendored
Normal file
28
IUT/Info1/TD/Exercices/10.9/.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"tasks": [
|
||||
{
|
||||
"type": "cppbuild",
|
||||
"label": "C/C++: g++ build active file",
|
||||
"command": "/usr/bin/g++",
|
||||
"args": [
|
||||
"-fdiagnostics-color=always",
|
||||
"-g",
|
||||
"*.cpp",
|
||||
"-o",
|
||||
"${fileDirname}/${fileBasenameNoExtension}"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${fileDirname}"
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"detail": "Task generated by Debugger."
|
||||
}
|
||||
],
|
||||
"version": "2.0.0"
|
||||
}
|
||||
10
IUT/Info1/TD/Exercices/10.9/10.9.md
Normal file
10
IUT/Info1/TD/Exercices/10.9/10.9.md
Normal file
@@ -0,0 +1,10 @@
|
||||
nomprenom : une fonction (nom : un tableau de caractères, prenom : un tableau de caractères) -> un tableau de caractères
|
||||
Lexique :
|
||||
nom_abrege : un tableau de caractères
|
||||
FCH : le caractère constant de fin de chaine de caractère
|
||||
Algorithme :
|
||||
Début
|
||||
|
||||
|
||||
|
||||
Fin
|
||||
BIN
IUT/Info1/TD/Exercices/10.9/fonction
Normal file
BIN
IUT/Info1/TD/Exercices/10.9/fonction
Normal file
Binary file not shown.
33
IUT/Info1/TD/Exercices/10.9/fonction.cpp
Normal file
33
IUT/Info1/TD/Exercices/10.9/fonction.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "fonction.h"
|
||||
|
||||
void nomprenom(
|
||||
const char nom[],
|
||||
const char prenom[],
|
||||
char pseudo[]
|
||||
) {
|
||||
unsigned int pos = 0;
|
||||
|
||||
for (unsigned int i = 0; i < 3 && nom[i] != '\000'; i++) {
|
||||
pseudo[pos] = prenom[i];
|
||||
}
|
||||
|
||||
pseudo[pos] = '-';
|
||||
pos++;
|
||||
|
||||
for (unsigned int i = 0; i < 3 && prenom[i] != '\000'; i++) {
|
||||
pseudo[pos] = nom[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Prof:
|
||||
|
||||
for i, i < 3 && prenom i != /0
|
||||
pseudo[pos] = prenom[i]
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
1
IUT/Info1/TD/Exercices/10.9/fonction.h
Normal file
1
IUT/Info1/TD/Exercices/10.9/fonction.h
Normal file
@@ -0,0 +1 @@
|
||||
void nomprenom(const char nom[], const char prenom[], char pseudo[]);
|
||||
BIN
IUT/Info1/TD/Exercices/10.9/main
Normal file
BIN
IUT/Info1/TD/Exercices/10.9/main
Normal file
Binary file not shown.
23
IUT/Info1/TD/Exercices/10.9/main.cpp
Normal file
23
IUT/Info1/TD/Exercices/10.9/main.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "fonction.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
char nom[1000];
|
||||
char prenom[1000];
|
||||
|
||||
const unsigned int _TAILLE_MAX = 8;
|
||||
char pseudo[_TAILLE_MAX];
|
||||
|
||||
cout << "Saisir nom et prenom" << endl;
|
||||
|
||||
cin >> prenom >> nom;
|
||||
|
||||
nomprenom(nom, prenom, pseudo);
|
||||
|
||||
cout << pseudo;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user