| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 911 人关注过本帖
标题:大佬帮忙看看 小白快疯了
只看楼主 加入收藏
wwswz
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2017-10-8
结帖率:0
收藏
已结贴  问题点数:20 回复次数:4 
大佬帮忙看看 小白快疯了
#include<stdio.h>
#include<string.h>
int main()
{
    char name[50];
    int id[9];
    float hight;
    printf("Please inter your name.");
    gets_s(name);
    int i;
    for (i = 1; i < 9; i++)
    {
        printf("Please inter the oder of %d in your id", i);
        scanf_s("%f", &id[i]);
    }
    printf("Please inter your hight in meter.");
    scanf_s("%f", &hight);// inter the hight//
    int a = strlen(name);
    int b;
    int c = 0;
    char name_rev[50];
    for (b = a; b >=0; b--)
    {
        name_rev[c] = name[b];
        c=c++;
    }
    printf("The reverse name is s%.\n", name_rev); 颠倒部分
    getchar();
    float d = id[1] + id[2] + id[3] + id[4];
    float e = id[5] + id[6] + id[7] + id[8];
    float f = d / e;
    printf("The addition of first 4 digits is %d.\n", d);
    printf("The addition of last 4 digits is %d.\n", e);
    printf("The division of them is %f.\n", f);
    getchar();
    float g = hight*3.02083;
    float h = g / 12;
    int j = g;
    int k = h;
    if (g - j < 0.5)
        j = j;
    else
        j = j++;
    if (h - k < 0.5)
        k = k;
    else
        k = k++;
    printf("Your hight is about %f feet and %f inch.\n", k, j);
    getchar();
    return 0;
   
}
颠倒输出的一直是s 算出的数全是整型 什么情况呀
搜索更多相关主题的帖子: int name float printf the 
2017-10-08 23:00
wwswz
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2017-10-8
收藏
得分:0 
数字的解决了 颠倒的还没搞懂
2017-10-08 23:22
wwswz
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2017-10-8
收藏
得分:0 
把不懂的地方整理出来了 帮忙看看呀
char name[50];
printf("Please inter your name.");
     gets_s(name);
char name_rev[50];
     for (b = a; b >=0; b--)
     {
         name_rev[c] = name[b];
         c=c++;
     }
     printf("The reverse name is s%.\n", name_rev);
2017-10-08 23:31
炎天
Rank: 13Rank: 13Rank: 13Rank: 13
来 自:桃花岛
等 级:贵宾
威 望:29
帖 子:1218
专家分:4986
注 册:2016-9-15
收藏
得分:10 
char name[50];  
printf("Please inter your name.");
     gets_s(name);
char name_rev[50];//char name_rev[50]={0}, 初始化, 不然会出现烫烫烫
     for (b = a; b >=0; b--)        //for(b=a-1;b>=0;b--)
     {
         name_rev[c] = name[b];
         c=c++;
     }
     printf("The reverse name is s%.\n", name_rev);

图片附件: 游客没有浏览图片的权限,请 登录注册



- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

程序代码:
#include<stdio.h>
#include<string.h>
int main()
{
    char name[50];
    float id[9];
    float hight;
    printf("Please inter your name.");
    gets_s(name);
    int i;
    for (i = 1; i < 9; i++)
    {
        printf("Please inter the oder of %d in your id", i);
        scanf_s("%f", &id[i]);
    }
    printf("Please inter your hight in meter.");
    scanf_s("%f", &hight);// inter the hight//
    int a = strlen(name);
    int b;
    int c = 0;
    char name_rev[50] = { 0 };
    for (b = a-1; b >= 0; b--)
    {
        name_rev[c] = name[b];
        c = c++;
    }
    
    printf("The reverse name is %s.\n", name_rev); //颠倒部分
        getchar();
    float d = id[1] + id[2] + id[3] + id[4];
    float e = id[5] + id[6] + id[7] + id[8];
    float f = d / e;
    printf("The addition of first 4 digits is %f.\n", d);
    printf("The addition of last 4 digits is %f.\n", e);
    printf("The division of them is %f.\n", f);
    getchar();
    
    float g = hight*3.02083;
    float h = g / 12;
    float j = g;
    float k = h;
    if (g - j < 0.5)
        j = j;
    else
        j = j++;
    if (h - k < 0.5)
        k = k;
    else
        k = k++;
    
    printf("Your hight is about %f feet and %f inch.\n", k, j);
    getchar();
    return 0;

}

早知做人那么辛苦!  当初不应该下凡
2017-10-09 00:59
九转星河
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:长长久久
等 级:贵宾
威 望:52
帖 子:5023
专家分:14003
注 册:2016-10-22
收藏
得分:10 
回复 4楼 炎天
嗯,挺认真嘛……还上图~

[code]/*~个性签名:bug是什么意思?bug是看上去没有可能的东西实际上是有可能做到的 就是这样~2018-08-08更~*/[/code]
2017-10-09 06:37
快速回复:大佬帮忙看看 小白快疯了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.027458 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved