標籤:os io 資料 for ar 時間 amp ios
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
int n,i;
char s[100];
char s1[100],s2[100],s3[100];
scanf("%d%*c",&n);
for(i=1;i<=n;i++)
{
gets(s1);
puts(s1);
}
}
題目96
題目資訊運行結果本題排行討論區n-1位元
時間限制:3000 ms | 記憶體限制:65535 KB
難度:1
描述
已知w是一個大於10但不大於1000000的不帶正負號的整數,若w是n(n≥2)位的整數,則求出w的後n-1位的數。
輸入
第一行為M,表示測試資料群組數。
接下來M行,每行包含一個測試資料。
輸出
輸出M行,每行為對應行的n-1位元(忽略首碼0)。如果除了最高位外,其餘位都為0,則輸出0。
範例輸入
4
1023
5923
923
1000範例輸出
23
923
23
0
// 用字串:
#include <iostream>
#include <cstring>
using namespace std;
int main()
{ char s[10];
int i,n,k,m,j;
cin>>m;
while(m--)
{
cin>>s;
k=strlen(s);
for(i=1;i<k;i++)
if(s[i]!=‘0‘)break;
if(i==k){ cout<<0<<endl;continue; }
for(j=i;j<k;j++)
cout<<s[j];
cout<<endl;
}
return 0;
}
#include<stdio.h>
int main()
{
int n;
int m;
scanf("%d",&n);
while(n--)
{
scanf("%d",&m);
if(m==1000000||m==100000||m==10000||m==1000||m==100||m==10)
m=0;
if(m>10&&m<100) m%=10;
else if(m<1000) m%=100;
else if(m<10000) m%=1000;
else if(m<100000) m%=10000;
else if (m<1000000) m%=100000;
printf("%d\n",m);
}
return 0;
}
#include<cstdio>
int main()
{
int n,m;
scanf("%d",&n);
while(n--)
{
scanf("\n%*c%d",&m); //輸入的內容去掉第一位 :如果輸入845,則M裡面放著45
printf("%d\n",m);
}
}