c_cpp Uri 1728 - (已接受)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp Uri 1728 - (已接受)相关的知识,希望对你有一定的参考价值。

/* Problema Difícil de Acreditar, Mas é Verdade! - Uri 1728
   Status - Accepted  
   By Antonio Abrantes                     */
   
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
	int i, j, num1, num2, result, soma, sair = 0, posi;
	char strNum1[15], strNum2[15], strResult[15], temp1[15], temp2[15], temp3[15];
	char equacao[100], aux[100];
	
	while(1){
	 scanf("%s", equacao);
	 posi = 0;
	 soma = 0;
	 for(i = 0; i < strlen(equacao); i++){
	 	if(equacao[i] == '+'){
			 strNum1[i] = '\0';
			 posi = i;
			 break;		 	 
		 }
		 strNum1[i] = equacao[i];		 
	 }
	 
	 strcpy(aux, equacao+posi+1);
	 strcpy(equacao, aux);

	 
	 for(i = 0; i < strlen(equacao); i++){
	 	if(equacao[i] == '='){
			 strNum2[i] = '\0';
			 posi = i;
			 break;
		 }
		 strNum2[i] = equacao[i];		 
	 }
	 
	 strcpy(aux, equacao+posi+1);
	 strcpy(strResult, aux);
	
	//Inverte as strings
	j = strlen(strNum1) - 1;
	for(i = 0; i < strlen(strNum1); i++){
		temp1[i] = 	strNum1[j];
		j--;		
	}
	temp1[strlen(strNum1)] = '\0';
	
	j = strlen(strNum2) - 1;
	for(i = 0; i < strlen(strNum2); i++){
		temp2[i] = 	strNum2[j];
		j--;		
	}
	temp2[strlen(strNum2)] = '\0';
	
	j = strlen(strResult) - 1;
	for(i = 0; i < strlen(strResult); i++){
		temp3[i] = 	strResult[j];
		j--;		
	}
	temp3[strlen(strResult)] = '\0';

		//Converte strings para inteiros
		num1 = atoi(temp1);
		num2 = atoi(temp2);
		result = atoi(temp3);
		
		if(num1 == 0 && num2 == 0 && result == 0){
			sair = 1; //Verifica condição de saida
		}
	
		soma = num1 + num2;

		if(soma == result){
			printf("True\n");
		}else{
			printf("False\n");
		}
	
		if(sair == 1){
			break;
		}
	}
	
	return 0;
}

以上是关于c_cpp Uri 1728 - (已接受)的主要内容,如果未能解决你的问题,请参考以下文章

c_cpp (Uri Judge)Problema 2033 C ++ - 接受

错误 1728 (HY000): 无法从 mysql.user 加载。该表可能已损坏

c_cpp 比赛Uri - Monopolio

c_cpp Uri 2033 - (WA 70%)

PHP面试随笔

http 错误代码表