起名大一C语言第一不成试:小学生教学系统

起名 1

尖端语言程序设计报告

Xcode 5.1.dmg 下充斥地址

 

http://pan.baidu.com/s/1jGJpKm6

打印版报告结束上交日期:2014年11 月 15 日

 

电子版报告作至2629610662@qq.com, 邮件标题写明报告次数序号姓名

1.新建 Framework & Library 工程

序号

起名 2

34

本人由名叫ShowInfo,下面为那源码

姓名

起名 3

许恺

showInfo.h

照片

=========================

 

#import <Foundation/Foundation.h>

成绩

@interface ShowInfo : NSObject

 

  • (void)showInfo;

E-MAIL及电话

@end

18810556775

=========================

见习题目

showInfo.m

先是赖作业: 函数

=========================

  1. 七段实验题之素数探求2-6
  2. 七回实验题之小学生计算机帮忙教学系统(用模块化程序设计方法就六节的任务6即可)
  3. 斯2题单独编程,即不在ACM系统受到就。
  4. 求概括使用本章所学内容(注释、起名规则、缩进等)。

#import “ShowInfo.h”

 

@implementation ShowInfo

 

  • (void)showInfo
    {
        NSLog(@”hello Y.X.”);
    }
  1. 君的代码、注释及运行结果贴图。
  2. 计划和调试过程遇到的题材同缓解方案。
  3. 心得体会和我对程序的评头品足。

@end

任务六

=========================

一、 代码和注释

 

//编辑人:许恺

2.分级打造真机以及模拟器使用的静态库

//编辑题目:小学生教学系统

起名 4

//时间: 12月2日

起名 5

 

起名 6

#include <stdlib.h>

若达到图所示,Debug-iphoneos以及Debug-iphonesimulator都出一个静态库文件

#include <stdio.h>

 

#include <time.h>

3.统一静态库

int Add(int a);

集合静态库的格式如下所示

int jianfa(int a);

lipo -create /绝对路径/libShowInfo.a  /绝对路径/libShowInfo.a  -output
/绝对路径/libShowInfo.a

int chengfa(int a);

起名 7

int chufa(int a);

居功至伟告成!

double pingjia(int d);

 

double pingjia1(int d);

以下也 Xcode 5.1 测试结果

int main()

起名 8

{

无意发现 Xcode 5.1 中之静态库 Search
Paths 中的门道为 $(PROJECT_DIR)
,以后再也不会出现换台电脑后再行设置库搜索路径的问题了.

  int e,a,b,c,d,f,g=0;

以下也 Xcode 5.0 测试结果

  do

起名 9 

  {

 

    for(e=1;e<=10;e++)             //出十道题

问:如果产生诸多文件,如何编译成一个静态库文件?

    {

起名 10

      srand(time(NULL));

假设达到例被,我以一个操作CoreData的多文书由包改成一个静态库,编译时拿用导出的头文件导出来即可(图片右侧下有).

      b=rand()%4+1;             //随机加减乘除

 

      switch(b)

咨询:为什么在采取静态库时报错呢?

      {

无限生或而的静态库文件中含有类目文件,就上述图中为条例,有诸多底类目文件,解决方法在
Other Linker Flags 是补加 -ObjC 标签,如下图所示

        case 1:f=Add(a);

起名 11

                 break;

原理分析如下
http://stackoverflow.com/questions/2567498/objective-c-categories-in-static-library/2615407#2615407

        case 2:f=jianfa(a);

Solution: As of Xcode 4.2, you only need to go to the application
that is linking against the library (not the library itself) and click
the project in the Project Navigator, click your app’s target, then
build settings, then search for “Other Linker Flags”, click the +
button, and add ‘-ObjC’. ‘-all_load’ and ‘-force_load’ are no longer
needed.

           break;

Details: I found some answers on various forums, blogs and apple
docs. Now I try make short summary of my searches and experiments.

        case 3:f=chengfa(a);

Problem was caused by (citation from apple Technical Q&A QA1490
http://developer.apple.com/mac/library/qa/qa2006/qa1490.html):

           break;

Objective-C does not define linker symbols for each function (or
method, in Objective-C) – instead, linker symbols are only generated
for each class. If you extend a pre-existing class with categories,
the linker does not know to associate the object code of the core
class implementation and the category implementation. This prevents
objects created in the resulting application from responding to a
selector that is defined in the category.

        case 4:f=chufa(a);

And their solution:

           break;

To resolve this issue, the static library should pass the -ObjC option
to the linker. This flag causes the linker to load every object file
in the library that defines an Objective-C class or category. While
this option will typically result in a larger executable (due to
additional object code loaded into the application), it will allow the
successful creation of effective Objective-C static libraries that
contain categories on existing classes.

        }

and there is also recommendation in iPhone Development FAQ:

      if(f==1)   g=g+10;          //算总分和正确率

How do I link all the Objective-C classes in a static library? Set the
Other Linker Flags build setting to -ObjC.

    }

and flags descriptions:

    printf(“%d %d%%\n”,g,g);

all_load Loads all members of static archive libraries.

ObjC Loads all members of static archive libraries that implement
an Objective-C class or category.

force_load (path_to_archive) Loads all members of the
specified static archive library. Note: -all_load forces all members
of all archives to be loaded. This option allows you to target a
specific archive.

      }while(g<=75);

*we can use force_load to reduce app binary size and to avoid
conflicts wich all_load can cause in some cases.

  return 0;

Yes, it works with *.a files added to the project. Yet I had troubles
with lib project added as direct dependency. But later I found that it
was my fault – direct dependency projecct possibly was not added
properly. When I remove it and add again with steps:

  }

  1. Drag&drop lib project file in app project (or add it with
    Project->Add to project…).
  2. Click on arrow at lib project icon – mylib.a file name shown, drag
    this mylib.a file and drop it into Target -> Link Binary With
    Library group.
  3. Open target info in fist page (General) and add my lib to
    dependencies list

int Add(int a)     //加法运算块

after that all works OK. “-ObjC” flag was enough in my case.

{

I also was interested with idea from
http://iphonedevelopmentexperiences.blogspot.com/2010/03/categories-in-static-library.html
blog. Author say he can use category from lib without setting -all_load
or -ObjC flag. He just add to category h/m files empty dummy class
interface/implementation to force linker use this file. And yes, this
trick do the job.

  int b,c,d;

But author also said he even not instantiated dummy object. Mm… As I’ve
found we should explicitly call some “real” code from category file. So
at least class function should be called. And we even need not dummy
class. Single c function do the same.

  srand(time(NULL));

So if we write lib files as:

  b=rand()%10+1;

// mylib.hvoid useMyLib();@interfaceNSObject(Logger)-(void)logSelf;@end// mylib.mvoid useMyLib(){NSLog(@"do nothing, just for make mylib linked");}@implementationNSObject(Logger)-(void)logSelf{NSLog(@"self is:%@",[self description]);}@end

  c=rand()%10+1;

and if we call useMyLib(); anywhere in App project then in any class we
can use logSelf category method;

  d=b+c;

[self logSelf];

  printf(“%d+%d=?\n”,b,c);

And more blogs on theme:

  scanf(“%d”,&a);

How to make an iPhone static library – part 1

     if(a==d)                       //判断正误并赶回数值

http://blog.costan.us/2009/12/fat-iphone-static-libraries-device-and.html

    {

 

    pingjia(d);         

咨询:合并静态库时为什么会报错?

      return 1;                    

要用您在采取的 Xcode 的 APP
文件名字修改成Xcode.app,否则在极限合并库文件时见面报错.

  }

起名 12

  else

  {

    pingjia1(d);

    return 0;}

  }

int jianfa(int a)               //减法运算块

{

int b,c,d;

do                           //防负数抽取

{

    srand(time(NULL));

b=rand()%10+1;

c=rand()%10+1;

}while(b<c);                   

d=b-c;     

printf(“%d-%d=?\n”,b,c);

scanf(“%d”,&a);

if(a==d)                              //判断正误并回到数值

{pingjia(d);

    return(1);}

else

{

pingjia1(d);

return 0;}

}

int chengfa(int a)

{

int b,c,d,e;

srand(time(NULL));

b=rand()%10+1;

c=rand()%10+1;

d=b*c;

printf(“%d*%d=?\n”,b,c);

scanf(“%d”,&a);

    if(a==d)                              //判断正误并返数值

    {pingjia(d);

    return 1;

}

else

{

pingjia1(d);

return 0;}

}

int chufa(int a)

{

int b,c,d,e;

do                                //防除不尽抽取

{

srand(time(NULL));

b=rand()%10+1;

c=rand()%10+1;

    }while(b<c||b%c!=0);

d=b/c;

printf(“%d/%d=?\n”,b,c);

scanf(“%d”,&a);

    if(a==d)                             //判断正误并返回数值

    {pingjia(d);

    return 1;

}

else

{

pingjia1(d);

return 0;}

}

double pingjia(int d)                 //赞扬的评价网

{

srand(time(NULL));

d=rand()%4+1;

switch(d)

{

case 1:printf(“Very good!\n”);

       break;

case 2:printf(“Excellent!\n”);

   break;

case 3:printf(“Nice work!\n”);

   break;

case 4:printf(“Keep up the good work!\n”);

   break;

    }

}

double pingjia1(int d)                //做错了之评网

{

srand(time(NULL));

d=rand()%4+1;

switch(d)

{

case 1:printf(“No.Please try again.\n”);

       break;

case 2:printf(“Wrong.Try once more.\n”);

   break;

case 3:printf(“Don’t give up!\n”);

   break;

case 4:printf(“Not correct.Keep trying.\n”);

   break;

    }

}

二、 运作结果贴图

 起名 13

 

三、 规划及调试过程中遇的题目同缓解方案

    遇到了关于switch语句和任意数不见面动用的状况,主要是书看的掉,经过看开之后曾解决。另外,还犯了for语句没有赋初值的谬误,被波波先生正,也曾改。一开始当主函数吃连连使用if使程序不入眼,看开后改成用switch.还有函数命名方面实际恶心,由于自家英语水平有限,目前尚非缓解。

四、 心得体会和我对先后的评介

        做事不要耽搁,看起很麻烦,当走来第一步,就可以为此复制粘贴去跑了,程序基本完好美观最要命缺憾就是到的时日最好晚,其实说之是系统,也就那么回事,以后几百实施的先后也未以谈下,用心去编,都没问题。但是对c的有些讲话和技能不绝了解,需要进一步努力,总的来说还行,已高达内心之规范。加油!!

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图