/ * longIntAdd * /
include <stdio. h>
include <string. h>
define LENGTH 81
void addLInt(char sl[],char s2[]); void reverse(char s[]) ; int main()
{
char intstrl[LENGTH],intstr2[LENGTH];
printf("请输入超长整数的被加数和加数:/n")
scanf("%s%s" ,intstrl ,intstr2) ; addLInt(intstrl ,intstr2) j printf("超长整数和为: %s" .intstrl); return 0;
}
void addLInt(char sl[] ,char s2[]) {
int i=0,tmp,c=0;
char s[LENGTH];
if(strlen(s1)<strlen(s2)){ strcpy(s,sl); strcpy(sl,s2); strcpy(s2,s);
}
reverse(sl);reverse(s2);
while(s2[i]! ='/0'){
tmp=sl[i]-'0'+s2[i]-'0'+ c;
sl[i] = tmp%10+,0';
c=tmp/10;
i++; } while(sl[i]! ='/0,&&c){
tmp=sl[i] —'0' + c;
sl[i] = tmp%10+'0';
c=tmp/10;
i++; } If(c){
sl[i++] = c+'0';
sl[i] = '/0'; } reverse(sl);
}
void reverse(cliar s[])
{
inti,j,c;
for(i=0,j = strlen(s) -l;i<j;i++,j--){
c=s[i]; s[i] = s[j]; s[j] = c; } }(1)画出程序中函数addLInt的控制流程图(10分);(2)设计一组测试用例,使该程序addLInt函数的语句覆盖率和分支覆盖率均能达到100%。如果认为该函数的语句覆盖率或分支覆盖率无法达到100%,需说明为什么(10分)。
[试题]已知C源程序如下: include include void reverse(char S[]){ int C,i,J; f已知C源程序如下:include<stdio. h>include<string. h>void reverse(char S[]){int C,i,J;for(i=0,j=strlen(s)-1;i<j;i++,j++){c=s[i];s[i]=s[j];s[j]=c;}}void getHex(int number,char s[]){int I;i=0;while(nu
[单选题]有如下程序include include using namespace std;class MyClass {public:M有如下程序#include <iostream>#include <iomanip>using namespace std; class MyClass {public:MyClass(){ cout<<'A'; }MyClass(char c){ cout<<c; }~MyClass(){ cout<<'B'; }};int main() {MyClass p
[单选题]有如下程序include include using namespace std;int main( ){cout<
[单选题]( 28 )有如下程序:#include<iostream>#include<cstring>using namespace std;class XCF{int a;public:XCF ( int aa=0 ) : a ( aa ) {cout<<"1" ; }XCF ( XCF& x ) {a=x .a; cout<<"2" ; )~XCF () {cout<<a;}int Geta () {return a;}};
[单选题]( 27 )有如下程序:#include<iostream>#include<cstring>using namespace std;class XCD{char* a;int b;public:XCD ( char* aa, int bb ) {a=new char[strlen ( aa ) +1];strcpty ( a,aa ) ;b=bb;}C.har* Geta () {return a; )int Getb () { return b;}};int main
[试题]针对以下C语言程序,请按要求回答问题。已知link. c源程序如下:/*link. c程序对单向链表进行操作,首先建立一个单向链表,然后根据用户的选择可以对其进行插入结点、删除结点和链表反转操作*/include<stdio. h>include<stdlib. h>typedef struct list_node * list_pointer; //定义链表指针typedef struct list_node{ //定义链表结构int data;list_pointer link;}list_n
[主观题]针对一下C语言程序,请按要求回答问题。 已知weekday. c源程序如下: include include
[单选题]有如下程序:include using namespace std;int s=0;class sample { static int n;publ有如下程序: #include <iostream> using namespace std; int s=0; class sample { static int n; public: sample(int i) { n=i; } static void add() { s+=n; } };A.2B.5C.7D.3
[单选题]有如下程序: <br>#include<br>using namespace std;<br>int main()<br>{<br>int *p;<br>*p =9;<br>cout<<"The value at p:"<<*p;<br>return 0;<br>}<br> 编译运行程序将出现的情况是 <br&g
[单选题]( 37 )有以下程序#include <stdio.h>#include <string.h>struct A{ int a; char b[10]; double c;};void f ( struct A t ) ;main (){ struct A a={1001, " ZhangDa " ,1098.0};f ( a ) ; printf ( " %d,%s,%6.1f/n " ,a.a,a.b,a.c ) ;}void f ( struct A t )