• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
烟酒妓
博客园    首页    新随笔    联系   管理    订阅  订阅

第七周

这个作业属于那个课程|C语言程序设计II|
| - - - - - - - - | :- - - - :| - - - -:|
|这个作业要求在哪里|熟练使用|
|我在这个课程的目标是|弄懂就行|
|这个作业在那个具体方面帮助我实现目标|搞钱|
|参考文献|书上的例题|

实验代码

void fun( char *p ){
	int i;
	for(i=0;*(p+i)!='\0';i++){
		if(*(p+i+1)==' ')
		*(p+i)=*(p+i)-'a'+'A';
	}
}

实验截图:

实验代码:

#include<stdio.h>
#include<string.h>
int main (void)
{
    int total = 0, change = 0, i = 0, sum;
    int n, num[11] = {0}, price[11]={0,1,1,1,2,2,3,3,3,4,4};
    char res[11][20]={"","Table-water","Table-water","Table-water","Coca-Cola","Milk","Beer","Oolong-Juice","Sprite","Oolong-Tea","Green-Tea"};

    while(1)
{
        scanf("%d", &n);
        if(n == -1)
        break; 
        total += n;

    }   
    while(1)
    {
        scanf("%d", &n);
        
        if(n == -1)
        break;
        
        num[n]++; 
    }
    
    for(i = 1;i < 11;i++)
    {
        change += price[i] * num[i];
    }
    
    if(change > total)
    {
        printf("Insufficient money");  
       return 0;
    }
    printf("Total:%dyuan,change:%dyuan\n", total, total - change);//输出价格
    
    for(i = 1;i < 11;i++)
    {
        if(num[i] != 0)
        {
            printf("%s:%d;", res[i], num[i]);
        }
    }
    
    return 0;
}

实验截图:

实验代码:

#include<stdio.h>
void delchar(char *str, char c);
int main(void)
{
    int repeat,i;
    char str[100],c;
    scanf("%d\n",&repeat);
    for(i=1;i<=repeat;i++){
        gets(str);
        c=getchar();
        delchar(str,c);
        printf("result: %s\n",str);
    }
    return 0;
}
void delchar(char *str, char c)
{
    int r,u=0;
    for(r=0;str[r]!='\0';r++){
        if(str[r]!=c){
            str[u]=str[r];
            u++;
        }
    }
    str[u]='\0';
}

实验截图:

实验总结:

|时间|这周所花时间|代码行数|学到的知识点|目前比较困惑的问题|
| - - - - - - - - |:- - - - :| - - - - :|
|3.4-3.11|三天|45|文件指针的建立,加密|对文件地址的寻找不是很清楚|
|3.12-3.16|7小时|76行|对于二维数组有了一些基本了解|矩阵术语还有一些不了解|
|3.17-3.22|五天|278|二维数组的学习与应用,选择排序,|二维数组的应用经常会与一维数组混淆|
|3.22-3.29|七天|记不清了|对于字符数组的用法、使用字符串编程有一定了解|不会使用代码解决回文问题|
|3.31-4.5|这肯定是好久了|学了一点的使用,不过比较懵|不清楚再什么时候使用,大概差不多的感觉|
|4.7-4.12|334|对数组的理解清晰了一点,通过借鉴一班助教的代码,理解更加清楚|对于循环问题的理解的不足|

posted @ 2019-04-12 17:44  烟酒*  阅读(201)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3