by k8 on Fri Oct 27, 2006 12:41 pm
- Code: Select all
/*
Descrizione:
Data La Seguente tabella di Numeri Creare un algoritmo che stampi n righe della sequenza:
d c s
1 2 3
3 3 6
6 4 10
10 5 15
15 6 21
*/
#include <stdio.h>
main()
{
int d = 1;
int c = 2;
int s = 3;
int count = 0;
int n = 0;
printf("Inserisci N");
scanf("%d",&n);
printf("%d %d %d\n",d,c,s);
count++;
do
{
d = s;
c = c++;
s = d + c;
count++;
printf("%d %d %d\n",d,c,s);
}
while(count < n);
return 0;
}
- Code: Select all
#include <stdio.h>
int main()
{
int a,b; /*Variabili A,B*/
int count =0; /*Contatore per i tentativi */
printf("\n****************************");
printf("\n*** Indovina Numero V1.0 ***");
printf("\n*** CodeD in C ***");
printf("\n*** By Keit ***");
printf("\n*** Helper: Gemo ***");
printf("\n****************************\n\n");
printf("Inserire Il Numero: ");
if ((scanf("%d",&a))==0) { /*Controlla che venga immesso un numero*/
return -1;
}
while(a!=b){ /*Finche A è diverso da B fai cio:*/
printf("Indovina il Numero: ");
if((scanf("%d",&b))==0){ /*Controlla che venga immesso un numero*/
return -1;
}
if(a>b){
printf("Maggiore\n");
count=count+1; /* Incremento il contatatore dei tentativi */
}
else if(a<b){
printf("Minore\n");
count=count+1; /*Incremento il contatore dei tentativi */
}
/*Stampando il valore del contatore */
}
count = count+1;
printf("Hai Indovinato con %d tentativi",count);
}
Big-Bug cerca collaboratori.
Scrivete senza abbreviazioni e senza k, grazie.