76-----80

76.#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
/*
    题目:八进制转换为十进制
    八进制456  =》  十进制 302
    302 = 6*pow(8,0)+5*pow(8,1)+4*pow(8,2)
*/
 
int main07()
{
    int n;
    scanf_s("%d", &n);
 
    int i = 0, sum = 0, tmp;
 
    while (n)
    {
        tmp = n % 10;
        sum += tmp * pow(8, i);
        n = n / 10;
        i++;
    }
 
    printf("%d", sum);
    return 0;
}

77.

#include <stdio.h>
#include <string.h>
void sort(char c[][81], int n)
{
    int i,j,k;
    char t[81];
    for(i=0; i<n-1; i++)
    {
        k=i;
        for(j=i+1; j<n; j++)
            if(strcmp(c[k],c[j]) > 0)
                k=j;
        if(k!=i)
        {
            strcpy(t,c[i]);
            strcpy(c[i],c[k]);
            strcpy(c[k],t);
        }
    }
}

int main()
{
    int i;
    char c[5][81]={0};
    for(i=0; i<5; i++)
        scanf("%s",c[i]);
    sort(c,5);
    printf("After sorted:\n");
    for(i=0; i<5; i++)
        printf("%s\n",c[i]);
    return 0;
}
78.#include<iostream>
using namespace std;
 
double* odd_Number(int n)    //n为奇数
{
    double sum=0;
    for(int i=1;i<=n;i+=2)
    {
        sum=sum+(float)1/i;<span style="white-space:pre">    </span>//注意此处使用的强制转换
    }
 
    return ∑
}
 
double* even_Number(int n)    //n为偶数
{
    double sum=0;
 
    for(int i=2;i<=n;i+=2)
    {
        sum=sum+(float)1/i;<span style="white-space:pre">    </span>//注意此处使用的强制转换
    }
 
    return ∑
}
 
int main()
{
    int N;
    double *Result=NULL;
    cin>>N;
    
    if(N%2==0)    //判断用户输入的是奇数还是偶数
    {
        Result=even_Number(N);
    }
    else
    {
        Result=odd_Number(N);
    }
    cout<<*Result<<endl;
    return 0;
}

79.

#include

struct men

{

int num;

char name[8];

char sex[8];

float score;

}boy[5];

void input()

{

int i;

for(i=0;i<5;i++)

{

printf("Input the number:\n");

scanf("%d",&boy[i].num);

printf("Input the name:\n");

scanf("%s",boy[i].name);

printf("Input the sex:\n");

scanf("%s",boy[i].sex);

printf("Input the score:\n");

scanf("%f",&boy[i].score);

}

}

void output()

{

int i;

for(i=0;i<5;i++)

{

printf("NUM\t\t\tNAME\t\t\tSEX\t\t\tSCORE\n\n");

printf("%d\t\t\t",boy[i].num);

printf("%s\t\t\t",boy[i].name);

printf("%c\t\t\t",boy[i].sex);

printf("%.2f\n",boy[i].score);

}

}

int main()

{

void input();

void output();

input();

output();

return (0);

}

80.不会做

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值