TOPIC

PROBLEM 1113 - URI Fórum 1.0

beecrowd asked on Feb 8 2013

URI Online Judge Fórum 1.0

MOD

This topic was solved and cannot recieve new replies.

  • gpires1 replied 8 years ago

    esta dando 100% errado qual é o meu erro?

    cont = 0
    while cont < 1:
        num = input().split()
        X = int(num[0])
        Y = int(num[1])
        if X == Y:
            cont += 1
        else:
            if X > Y:
                print("Decrecente")
            if X < Y:
                print("Crecente")
  • mjxavier replied 8 years ago

    Alguem me ajuda? Worng answer 20%

    #include <stdio.h>
    #include <stdlib.h>
    int main()
    {
        int x,y;
        scanf("%i",&x);
        scanf("%i",&y);
        if(x<y)
            printf("Crescente\n");
        if(x>y)
            printf("Decrescente\n");
        else
            printf("\n");
        return 0;
    }
  • ajsilva replied 8 years ago

  • ajsilva replied 8 years ago

    RESOLVIDO:

    include

    int main() {

    int X,Y;

    scanf("%i %i",&X,&Y); do{

    if(X<Y)
        printf("Crescente\n");
    else
        printf("Decrescente\n");
    scanf("%i %i",&X,&Y);

    }while(X!=Y);

    return 0;

    }

  • ahed_alrashaida replied 8 years ago

    Hi my friends. I submit next code and get WA 20%. I prove with cases in both code and toolkit, and obtain the same results. Can you help me to find the problem.

    import java.util.Scanner;

    public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc = new Scanner(System.in); 
        for (int i=1 ; i<=3 ; i++){
        int x = sc.nextInt();
        int y = sc.nextInt();
        if(x<y)
            System.out.println("Crescente");
        if(x>y)
            System.out.println("Decrescente");
        else
            System.out.println();
        }
    
    }

    }

  • erodrigues replied 9 years ago

    Está ao contrário (:

    MOD
  • vsdmelo replied 9 years ago

    Oi. Alguém pode me ajudar? O URI diz wrong answer, mas nao sei o que esta errado.

    Eis o código:

    #include<stdio.h>
    
      int main(){
    
        int X = 0, Y = 1;
        while(X!=Y){
          scanf("%d %d",&X,&Y);
          if(X > Y)
           printf("Crescente\n");
          if(X < Y)
           printf("Decrescente\n"); 
    
        }
      return 0;
      }
  • erodrigues replied 9 years ago

    Você importou o Scanner?

    MOD
  • renanh replied 9 years ago

    está dando erro na linha 4 no Scanner console = new Scanner(System.in); sempre usei assim aqui e agora está dando erro nisso

    public class Main{
    
        public static void main(String[] args) {
            Scanner console = new Scanner(System.in);
    
            for (int i = 0; i < 4; i++) {
                int x = console.nextInt();
                int y = console.nextInt();
    
                if (x > y) {
                    System.out.println("Decrescente");
                }
    
                else if (x < y) {
                    System.out.println("Crescente");
                }
            }
        }
    }
  • erodrigues replied 9 years ago

    Apenas conserte a maneira como a palavra "Decrescente" está escrita.

    MOD
  • ssoares0 replied 9 years ago

    Dúvida respondida, Obrigado.

  • erodrigues replied 9 years ago

    Na declaração mesmo:

    int x = 0, y = 0;

    Nesse caso, eles precisam ser diferentes pra entrar no loop, então pode fazer isso:

    int x = 0, y = 1;

    Não tem problema inicializar eles com esses valores pois eles serão lidos logo no começo do while.

    MOD
  • ssoares0 replied 9 years ago

    Como eu faria isso, Erich? Colocaria x=0 e y=0 dentro do while??

  • erodrigues replied 9 years ago

    Lembre-se de inicializar as variáveis, principalmente se estiver as usando para controlar algum loop, ou condição.

    MOD
  • mgenova replied 9 years ago

    O que tem de errado?

    #include <stdio.h>
    #include <stdlib.h>
    
    int main() {
        int x,y;
        while(x!=y) {
        scanf("%d %d", &x,&y); 
        if(x>y) {
        printf("Descrescente\n"); }
        if(x<y) {
        printf("Crescente\n"); }
    }
    
    }
  • ggroth replied on May 2 2013

    Em vez de salvar a resposta em um vetor, vc já pode imprimi-la no momento que faz o teste se é crescente ou decrescente. Dessa forma não precisa fazer o for (que está percorrendo uma posição a mais do que o necessário). Além disso, podem haver mais testes do que apenas os 50 que vc colocou no vetor.

  • vrodrigues replied on May 2 2013

    Recebi "Wrong Answer" no código abaixo e não sei onde errei, testei várias vezes.

    Dúvida respondida. Código Removido!
  • ggroth replied on Apr 19 2013

    Cara, tenta pensar da seguinte forma. Você lê o x e o y, antes do while, correto? E você vai ficar iterando enquanto o x é diferente do y, certo? Mas se você nunca ler novamente o x e o y dentro do while, o valor deles nunca vai alterar, e vc cai em um loop infinido ;)

  • mvcdsouza replied on Apr 19 2013

    esta dando loop infinito no meu codigo em vez de ele voltar ao teste, sou novato em codigo de repetiçao. aqui o meu codigo

    Dúvida respondida. Código Removido!
  • ggroth replied on Mar 7 2013

    Camila Santos ou Elton Camargo, favor removerem o código, pois ganhou AC. Obrigado

1 of 2