|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- #include<stdio.h>
- int main()
- {
- char c;
- int a;
- int b;
- float r;
- scanf("%d%c%d",&a,&c,&b);
- r = (float)a/b;
- printf("%d %c %d\n",a,c,b);
- printf("%d %d %d %d %d\n",a + b,a - b,a * b,a / b,a % b);
- printf("The ratio of %d versus %d is %.2f.\n",a,b,r);
- printf("The ratio of %d / %d is %.2f%%\n",a,b,r*100);
-
- return 0;
-
- }
复制代码
为什么我这段代码不能按照我想要的来运行呢?‘
本帖最后由 jackz007 于 2023-9-27 14:56 编辑
- #include<stdio.h>
- int main(void)
- {
- int a , b , c ;
- scanf("%d%d%d" , & a , & b , & c) ;
- printf("%d %d %d\n" , a , b , c) ;
- printf("%d %d %d %.2f %d\n" , a + b , a - b , a * b , 1.0 * a / b , a % b) ;
- printf("The ratio of %d versus %d is %.2f.\n" , a , b , 1.0 * a / b) ;
- printf("The ratio of %d / %d is %.2f%%\n" , a , b , 100.0 * a / b) ;
- }
复制代码
编译、运行实况:
- D:\[exercise]\C>g++ -o x3 x3.c
- D:\[exercise]\C>x3
- 12345 23456 34567
- 12345 23456 34567
- 35801 -11111 289564320 0.53 12345
- The ratio of 12345 versus 23456 is 0.53.
- The ratio of 12345 / 23456 is 52.63%
- D:\[exercise]\C>
复制代码
|
-
|