1 solutions
-
0
C :
#include<stdio.h> int main() { int a,b,c,d; scanf("%d",&a); b=a%10; c=a/100; d=a/10-c*10; printf("%.2f",(c+d)*1.0/(b+d)); return 0; }
C++ :
#include <iostream> #include <iomanip> using namespace std; int main(){ int n,g,s,b; cin>>n; b = n / 100; s = n / 10 % 10; g = n % 10; cout<<fixed<<setprecision(2)<<(b+s)*1.0/(s+g); }
Java :
import java.util.Scanner; public class Main { /** * @param args */ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int g = a%10; int s = a/10%10; int b = a/100; double sum = (double)(b+s)/(s+g); System.out.println(String.format("%.2f", sum)); } public static void printArr(int [] a){ for (int i = 0 ;i<= a.length - 1 ;i++) { System.out.print( a[i] + " "); } } }
Python :
n = int(input()) b = n // 100 % 10 s = n // 10 % 10 g = n // 1 % 10 x = b + s y = s + g print("%.2f" % (x / y))
- 1
Information
- ID
- 10179
- Time
- 1000ms
- Memory
- 64MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By