rafzk Posted November 9, 2009 at 03:07 PM Report Share #295254 Posted November 9, 2009 at 03:07 PM Escreva um programa em C que apresente no ecrã um quadrado de números como o que se segue. Para isso deverá pedir ao utilizador o valor de N que deverá ser obrigatoriamente maior ou igual 2. O quadrado apresentado é o exemplo para N = 5. 1 2 3 4 5 2 3 4 5 6 3 4 5 6 7 4 5 6 7 8 5 6 7 8 9 Como se faz isto? Link to comment Share on other sites More sharing options...
rafzk Posted November 9, 2009 at 03:37 PM Author Report Share #295261 Posted November 9, 2009 at 03:37 PM #include <stdio.h> main() { int i,num,cont,j; do { printf("Digite um Numero: "); scanf("%d",&num); }while(num<=2); cont=0; for (i=1; i<=num; i++) // linha { for(j=0;j<num;j++){ // coluna cont++; printf("%d ",cont); } printf("\n"); cont=cont-(num-1); } } Link to comment Share on other sites More sharing options...
rafzk Posted November 9, 2009 at 03:38 PM Author Report Share #295262 Posted November 9, 2009 at 03:38 PM Ja consegui resolver. Obrigado anyway! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now