Home page

Teacher

On

line

Il sito

Competenze da acquisire

Regole didattiche

Contatore visite
 (dal 18-10-07)
Hit Counter
  Esercitazion PON / TIC Album Fotografico ricreazione_e_video Forum didattico Progetti Alunni Corsi per docenti Download    

IIS: Ragioneria

1°Anno  CAT

2°Anno AFM

3° Anno AFM

3° Anno  SIA

4°Anno AFM

4°Anno SIA

5°Anno SIA


Algoritmi fondamentali


Flow Chart


Codice


Ricordi

Statistiche


Algoritmi fondamentali:

Flow Chart

Codice


Ricordi

Statistiche

Per coordinare le attività inerenti a un campionato di calcio, si conservano le informazioni relative a tutte le squadre  che vi partecipano in un archivio SQUADRE che contiene i seguenti campi:

NOME SQUADRA

PUNTI

PARTITE VINTE

PARTITE PAREGGIATE

PARTITE PERSE.

Nel file PARTITE sono memorizzate, per ciascuna squadra, i punti che questa ha guadagnato in una giornata di campionato.

1. Creare un nuovo file NEWSQUA che contenga le informazioni del file SQUADRE, aggiornate con quelle contenute nel file PARTITE

2. Stampare la classifica

'NELLA SOLUZIONE MANCANO LE ISTRUZIONI DI ASSEGNAZIONE, LE CONDIZIONI e GLI INPUT

Option Explicit
Const numsquadre = 20
Private Type t_squadre
noms As String * 20 'nome squadra
punti As Byte
pv As Byte 'partite vinte
ppar As Byte 'partite pareggiate
pperse As Byte 'partite perse
End Type


Private Type partite
nom As String * 20 'nome squadra
punt As Byte 'punti (3,1,0) ottenuti in una giornata di campionato
End Type
Dim tabel(1 To numsquadre) As t_squadre

Dim sq As t_squadre
'Caricamento squadre (ogni volta che si esegue sovrascrive quelle già esistenti
Sub caricaSquadre()
Dim i As Integer
Dim J As Integer
Dim sq As t_squadre
Dim risp As String
Open "A:\squadre.dat" For Random As 1
i = 0
Do
sq.noms = InputBox("dammi il nome della squadra")
sq.pv = InputBox("dammi il numero di partite vinte")
sq.ppar = InputBox("dammi il numero di partite pareggiate")
sq.pperse = InputBox("dammi il numero di partite perse")
sq.punti = sq.pv * 3 + sq.ppar
i = i + 1
Put #1, i, sq
risp = InputBox("Vuoi continuare?")
Loop Until risp = "no"
Close 1
End Sub

Private Sub carica_partite()
Dim i As Integer
Dim part As partite
Dim risp As String * 2
Open "A:\partite.dat" For Random As #2
i = 1
Do
part.nom = InputBox("dammi il nome della squadra che ha giocato")
part.punt = InputBox("dammi i punti guadagnati")
Put #2, i, part
risp = InputBox("altre squadre da inserire?(si/no)")
i = i + 1
Loop Until risp = "no"
Close 2
End Sub
Private Sub elencoSquadre()
Dim mess As String
Dim sq As t_squadre
Dim i As Byte
Dim numrec As Integer
Open "A:\squadre.dat" For Random As 1 Len = Len(sq)
mess = mess & " SQUADRA " & " PUNTI " & " VINTE " & " PAREGGIATE " & " PERSE" & Chr(10) & Chr(13)
i = 1
numrec = LOF(1) / Len(sq)
Do While i <= numrec
Get #1, i, sq
mess = mess & sq.noms & " " & sq.punti & " " & sq.pv & " " & sq.ppar & " " & sq.ppar & Chr(10) & Chr(13)
i = i + 1
Loop
MsgBox mess
Close 1
End Sub
Private Sub elencoPartite()
Dim mess As String
Dim part As partite
Dim i As Byte
Dim numrec As Integer
Open "A:\partite.dat" For Random As 2 Len = Len(part)
mess = mess & " SQUADRA " & " PUNTI " & Chr(10) & Chr(13)
i = 1
numrec = LOF(2) / Len(part)
Do While i <= numrec
Get #2, i, part
mess = mess & part.nom & " " & part.punt & Chr(10) & Chr(13)
i = i + 1
Loop
MsgBox mess
Close 2
End Sub

'creare un nuovo file NEWSQUA che contenga le informazioni del file SQUADRE aggiornate con
'quelle contenute nel file PARTITE

Sub aggiorna() 'punto 1
Dim i As Integer
Dim J As Integer
Dim NUMREC1 As Single
Dim NUMREC2 As Single
Dim sq As t_squadre
Dim trovato As Boolean
Dim part As partite
Open "A:\squadre.dat" For Random As 1 Len = Len(sq)
Open "A:\partite.dat" For Random As 2 Len = Len(part)
.......... 'calcola il numero di squadre nel file SQUADRE
............ 'calcola il numero di squadre nel file PARTITE
..........
Do While ........... ' finchè ci sono PARTITE
Get #2, J, part
.............
............ 'fai ricerca completa con flag sul file SQUADRE
Do While .......... And ............
Get #1, i, sq
If .............. Then
.........
Else
............
End If
Loop
If .............. Then 'se l 'hai trovata
................. 'aggiorna i punti complessivi
If ............ Then 'se la squadra ha perso
................ 'aggiorna il n° partite perse
Else
If ........... Then 'se ha pareggiato
................ 'aggiorna le partite pareggiate
Else
............... 'aggiorna le partite vinte
End If
End If
Put #1, i, sq
Else
MsgBox ("squadra non trovata")
End If
............
Loop
Close 1
Close 2
End Sub
Sub classifica()
Dim J As Integer
Dim i As Integer
Dim mess As String
Dim numrec As Integer
Dim part As partite
Open "a:\squadre.dat" For Random As 1 Len = Len(sq)
.............
For .... To ......
Get #1, i, sq
poniinordine
Next
For .... To .... per ciscuna squadra
.............. aggiorna mess con i suoi dati
Next
MsgBox mess
Close 1
End Sub

'pone in ordine sq nella tabella tabel di squadre man mano caricate
Sub poniinordine()
Dim i As Integer
Dim J As Integer
Dim y As Integer
Dim numrec As Single
...........
Do While ..................
..........
Loop
For ............... To ........... Step -1
..................
Next
................
End Sub

Private Sub Command1_Click()
caricaSquadre
End Sub

Private Sub Command2_Click()
aggiorna
End Sub

Private Sub Command3_Click()
classifica
End Sub

Private Sub Command4_Click()
carica_partite
End Sub

Private Sub Command5_Click()
elencoSquadre
End Sub

Private Sub Command6_Click()
elencoPartite
End Sub