1
Make a program to print:
1
2 2
3 3 3
.....
n n n n n n ... n
for a user-informed n. Use a function that takes an integer n value and prints up to nth line.
Why doesn’t it work?
#include <stdio.h>
#include <stdlib.h>
void tarefa(int r){
int e;
for (e=0; e<=r;e++){
printf(" %d ", e);
}
}
int main(int argc, char *argv[]) {
int x, j;
scanf("%d", &x);
for(j=0; j<=x; j++){
tarefa(j);
}
return 0;
}
Error? Which one? Or if there is no error, which is the output of the program? Have you tried the table test?
– Woss
What is the error? You are not printing what you should or are dropping any fault during execution?
– Jefferson Quesado
Is it the lack of a line end? Note also that you do not need (nor should) pass argument 0
– Jefferson Quesado
the problem was in the compiler...
– Pedro Joao
is already working
– Pedro Joao
Then post what you did to resolve the question as an answer, and help the next people who come across this same problem
– Jefferson Quesado
The problem was not in the compiler, the problem is never in the compiler. And can do whatever is not going to solve, the algorithm was wrong.
– Maniero
bigown has already solved... I also did in the ideone: https://ideone.com/vOCB9O
– Rovann Linhalis
thanks ai...nn was working out msm
– Pedro Joao
@Rovannlinhalis, in matters of competitive programming, usually they specify for the line break to be only the
\n
. In such cases, perhaps your code could generate aPresentation Error
in the BOCA or in the URI Judge.– Jefferson Quesado
@Pedrojoao The answer solved your question? Do you think you can accept it? See [tour] if you don’t know how to do it. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).
– Maniero
@Pedrojoao? Maniero’s answer answered your question?
– Jefferson Quesado