65,206
社区成员
发帖
与我相关
我的任务
分享
string str(n, '1');
cout << str;
bitset<N>BitS;
BitS.set();
cout<<BitS.to_string()<<endl;
memset(str, '1', n);
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
int main()
{
int n = 0;
char* str = 0;
printf("input count of 1 : ");
if (scanf("%d", &n) != 1 || n <= 0)
{
printf("input errror\n");
return 1;
}
str = (char*)malloc(n + 1);
memset(str, '1', n);
str[n] = 0;
printf("%s\n", str);
free(str);
return 0;
}
int n;
cin>>n;
int count=1;
if (n<0)
cout<<"error"<<endl;
else if (n==0)
cout<<"0";
else if(n==1)
cout<<"1"
for(int temp=2;temp<=n;temp++)
{
count*=10;
count=count+1;
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
int n = 10;
for (int i = 0; i < n; ++i)
cout << '1';
cout << endl;
string str(n, '1');
cout << str;
return 0;
}