日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

2018【比特杯】编程大赛

發布時間:2024/10/8 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 2018【比特杯】编程大赛 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2018【比特杯】編程大賽

1. D

#include <cstdio> #include <cstring> #include <algorithm> #include<iostream> using namespace std; typedef long long LL; int main(){int a=10;int x=a++;printf("a=%d x=%d\n",a,x);//a=11,x=10return 0; }

2.C

#include <cstdio> #include <cstring> #include <algorithm> #include<iostream> using namespace std; typedef long long LL; int main(){char acX[]="abcdefg";char acY[]={'a','b','c','d','e','f','g'};int lenx=strlen(acX);int leny=strlen(acY);printf("lenx=%d,leny=%d\n",lenx,leny);return 0; }

?

3.指針:C

#include <cstdio> #include <cstring> #include <algorithm> #include<iostream> using namespace std; typedef long long LL; int main(){unsigned long pulArray[]={6,7,8,9,10};unsigned long *pulptr;pulptr=pulArray;*(pulptr+3)+=3;printf("%d,%d\n",*pulptr,*(pulptr+3));//6,12return 0; }

4.聯合體:A

#include <cstdio> #include <cstring> #include <algorithm> #include<iostream> using namespace std; typedef long long LL; int main(){union{short k;char i[2];}*s,a;s=&a;s->i[0]=0x39;s->i[1]=0x38;printf("%x\n",a.k);//3839return 0; }

?

5.數據溢出:C

#include <cstdio> #include <cstring> #include <algorithm> #include<iostream> using namespace std; typedef long long LL; int main(){unsigned char a=200;unsigned char b=100;unsigned char c;c=a+b;printf("%d %d\n",a+b,c);//300,44//300-2^8=44return 0; }

?6.宏定義:B

#include <cstdio> #include <cstring> #include <algorithm> #include<iostream> using namespace std; typedef long long LL; #define SQUARE(x) x*x #define SQUARE2(x) (x)*(x) int main(){//預處理:printf("%d\n",1+2*1+2);printf("%d\n",SQUARE(1+2));//5//預處理:printf("%d\n",(1+2)*(1+2));printf("%d\n",SQUARE2(1+2));//9return 0; }

7.結構體:D

#include <cstdio> #include <cstring> #include <algorithm> #include<iostream> using namespace std; typedef long long LL; struct Test{int i;double d;char c; };int main(){struct Test T;printf("%d\n",sizeof(T));//24return 0; }

?8.D

#include <cstdio> #include <cstring> #include <algorithm> #include<iostream> using namespace std; typedef long long LL; unsigned short *sum(unsigned char a,unsigned char b){unsigned short s=0;s=a+b;return &s; } int main(){unsigned short *p=NULL;unsigned char a=1,b=2;p=sum(a,b);printf("%u+%u=%u\n",a,b,*p);//1+2=3return 0; }

填空題1?

#include <cstdio> #include <cstring> #include <algorithm> #include<iostream> using namespace std; typedef long long LL;int main(){char *pcColor="CSOFTX3000";char acColor[]="CSOFTX3000";printf("%d\n",strlen(pcColor));//10printf("%d\n",strlen(acColor));//10printf("%d\n",sizeof(pcColor));//4printf("%d\n",sizeof(acColor));//11,字符串結束標志'\0'return 0; }

?

?

填空題2?

#include <cstdio> #include <cstring> #include <algorithm> #include<iostream> using namespace std; typedef long long LL; unsigned short* pucCharArray[10][10]; typedef union unRec{unsigned long ullndex;unsigned short usLeve[7];unsigned char ucPos; }REC_S; int main(){REC_S stMax,*pstMax;printf("%d\n",sizeof(pucCharArray));//400printf("%d\n",sizeof(stMax));//16printf("%d\n",sizeof(pstMax));//4printf("%d\n",sizeof(*pstMax));//16return 0; }

填空題3

#include <cstdio> #include <cstring> #include <algorithm> #include<iostream> using namespace std; typedef long long LL;int main(){unsigned char puc[4];struct tagPIM{unsigned char ucPim1;unsigned char ucData0:1;unsigned char ucData1:2;unsigned char ucData2:3;}*pstPimData;pstPimData=(struct tagPIM*)puc;memset(puc,0,4);pstPimData->ucPim1=2;pstPimData->ucData0=3;pstPimData->ucData1=4;pstPimData->ucData2=5;printf("%02x %02x %02x %02x\n",puc[0],puc[1],puc[2],puc[3]);//02,29,00,00printf("%02d %02d %02d %02d\n",puc[0],puc[1],puc[2],puc[3]);return 0; }

編程題1:

#include <cstdio> #include <cstring> #include <algorithm> #include<iostream> using namespace std; typedef long long LL; int fun(int a[],int n)//0~n-1 {int cnt=1;for(int i=1;i<n;i++){if(a[i]!=a[i-1]){a[cnt++]=a[i];}}for(int i=0;i<cnt;i++)printf("%d\n",a[i]);return cnt; } int main(){int a[]={1, 1, 2, 2, 3, 4, 5, 6, 6};printf("%d\n",fun(a,sizeof(a)/sizeof(a[0])));return 0; }

?編程題2:

#include <cstdio> #include <cstring> #include <algorithm> #include<iostream> using namespace std; typedef long long LL; int fun(int k,int a[],int n,int b[],int m)//0~n-1,0~m-1 {int tot=0;int i=0,j=0;while(i<n&&j<m){if(a[i]<b[j]){tot++;if(tot==k) return a[i];i++;//c[tot++]=a[i],i++;}else{tot++;if(tot==k) return b[j];j++;//c[tot++]=b[j],j++;}}while(i<n){//c[tot++]=a[i],i++;tot++;if(tot==k) return a[i];i++;}while(j<m){//c[tot++]=b[j],j++;tot++;if(tot==k) return b[j];j++;} } int main(){int a[]={1, 3, 5, 7, 9, 11, 13 };int b[]={ 2, 4, 6, 8, 10};printf("%d\n",fun(5,a,7,b,5));return 0; }

編程題3

#include <cstdio> #include <cstring> #include <algorithm> #include<iostream> using namespace std; typedef long long LL; class Date { public:Date(int year=1900,int month=1,int day=1):_year(year),_month(month),_day(day){//檢查如果輸入參數是非法時間,初始化為1900-1-1if(CheckIsInvaildDate()){year=1900;month=1;day=1;}}Date(const Date& d):_year(d.year),_month(month),_day(day){}Date& operator =(const Date& d){if(this!=d){this._year=d._year;this._month=d._month;this._day=d._day;}return *this;}//檢查時間是否有效bool CheckIsInvaildDate(){if(_year<1||(_month<1||_month>12)||(_day<1||_day>DateOfMonth(_year,_month)))return true;return false;}void Display(){cout<<_year<<"-"<<_month<<"-"<<_day<<endl<<endl;}};

總結

以上是生活随笔為你收集整理的2018【比特杯】编程大赛的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。